PHP code example of ob-ivan / sd-profiler

1. Go to this page and download the library: Download ob-ivan/sd-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/ */

    

ob-ivan / sd-profiler example snippets


profiler()->init([
    'append' => true,
    // or:
    'firephp' => true,
);
register_shutdown_function(function () {
    profiler()->dispatch();
});

if (isset($_COOKIE['secretcookie']) && $_COOKIE['secretcookie'] === 'secretvalue') {
    profiler()->init([
        'firephp' => true,
    ]);
    // Dispatch profiling result before WP forcefully closes all output buffers.
    add_action(
        'shutdown',
        function () {
            profiler()->dispatch();
        },
        0
    );
}

profiler()->in('my_function', $vars);
my_function($vars);
profiler()->out('my_function');

function my_function($vars) {
    profiler()->log('my_function', $vars);
    // useful stuff here...
}