PHP code example of imhelle / yii2-xhprof-lib

1. Go to this page and download the library: Download imhelle/yii2-xhprof-lib 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/ */

    

imhelle / yii2-xhprof-lib example snippets


return [
    'bootstrap' => [
        'xhprof'
    ],
    'components' => [
        'xhprof' => [
            'class' => 'imhelle\xhprof\XHProfComponent',
            'libPath' => '/full/path/to/xhprof_lib',
            'htmlReportBaseUrl' => 'http://url.to/xhprof_html',
        ],
    ],
];

return [
    'bootstrap' => [
        'debug',
        'xhprof'
    ],
    'components' => [
        'debug' => [
            // ... other debug config options ...
            'panels' => [
                'xhprof' => [
                    'class' => 'imhelle\xhprof\XHProfPanel'
                ]
            ]
        ],
    ],
];

// create and configure instance of XHProf class
\imhelle\xhprof\XHProf::getInstance()->configure(array(
    'flagNoBuiltins' => true,
    'flagCpu' => false,
    'flagMemory' => true,
    'runNamespace' => 'my-cool-namespace',
    'libPath' => '/var/www/html/xhprof/xhprof_lib',
    'htmlUrlPath' => 'http://test.local/xhprof/xhprof_html'
));

// start profiler
\imhelle\xhprof\XHProf::getInstance()->run();

// stop profiler and get URLs to results and callgraph
$urls = \imhelle\xhprof\XHProf::getInstance()->stop();

// Links:
// $urls[\imhelle\xhprof\XHProf::TYPE_REPORT]
// $urls[\imhelle\xhprof\XHProf::TYPE_CALLGRAPH]