PHP code example of justbetter / magento2-xhprof-profiler

1. Go to this page and download the library: Download justbetter/magento2-xhprof-profiler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

justbetter / magento2-xhprof-profiler example snippets


return [
    // ... other configurations ...
    'xhprofprofiler' => [
        'app_name' => 'Magento 247',
        'endpoint' => 'http://exciting_chatelet.orb.local/profiler/store'
    ],
];

return [
    // ... other configurations ...
    'xhprofprofiler' => [
        'app_name' => 'Magento 247',
        'endpoint' => 'http://your_buggregator_instance/profiler/store'
    ],
];

namespace JustBetter\XhprofProfiler\Plugin;

use JustBetter\XhprofProfiler\Model\Profiler\XhprofProfiler;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\AppInterface as Application;

class AppInterfacePlugin
{
    public function __construct(
        protected XhprofProfiler $profiler
    )
    {
    }

    public function aroundLaunch(
        Application $subject,
        callable $proceed,
    ) : ResponseInterface {
        $this->profiler->handle();
        $response = $proceed();
        $this->profiler->terminate();
        return $response;
    }
}