Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XHPROF_FLAGS_CPU for xhprof, cleanup for ddev get #6

Merged

Conversation

stasadev
Copy link
Contributor

@stasadev stasadev commented Oct 28, 2024

The Issue

How This PR Solves The Issue

Adds XHPROF_FLAGS_CPU flag.
Cleanup for ddev get

Manual Testing Instructions

mkdir xhprof-test && cd xhprof-test
ddev config --auto
ddev add-on get https://github.com/iljapolanskis/ddev-buggregator/tarball/main
ddev composer require --dev spiral-packages/profiler
ddev restart

Using https://docs.buggregator.dev/config/xhprof.html#vanilla-php

Create index.php:

<?php

require_once __DIR__."/vendor/autoload.php";

use SpiralPackages\Profiler\Profiler;
use SpiralPackages\Profiler\DriverFactory;
use SpiralPackages\Profiler\Storage\WebStorage;
use Symfony\Component\HttpClient\NativeHttpClient;

$storage = new WebStorage(
    new NativeHttpClient(),
    'http://buggregator:8000/api/profiler/store',
);

$driver = DriverFactory::detect();

$profiler = new Profiler(
    storage: $storage,
    driver: $driver,
    appName: 'My super app',
    tags: [
        // global tags
        'env' => 'local',
    ]
);

$profiler->start(ignoredFunctions: []);

echo 'Hello World';

$profiler->end(tags: [
    // Tags for specific requests
]);

And:

ddev xhprof on
ddev launch
ddev launch :8000/#profiler

The data from xhprof should be here:

image

And click it:

image

@iljapolanskis iljapolanskis merged commit 0b83078 into iljapolanskis:main Oct 28, 2024
1 of 2 checks passed
@stasadev stasadev deleted the 20241028_stasadev_xhprof_cpu branch October 29, 2024 09:16
@stasadev
Copy link
Contributor Author

@iljapolanskis, this change also needs a new release, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants