1. Go to this page and download the library: Download aterrien/forp-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/ */
aterrien / forp-profiler example snippets
// first thing to do, enable forp profiler
forp_start();
// here, our PHP code we want to profile
function foo()
{
echo "Hello world !\n";
};
foo();
// stop forp buffering
forp_end();
// get the stack as an array
$profileStack = forp_dump();
print_r($profileStack);
// first thing to do, enable forp profiler
forp_start();
/**
* here, our PHP code we want to profile
* with annotations
*
* @ProfileGroup("Test")
* @ProfileCaption("Foo #1")
* @ProfileAlias("foo")
*/
function fooWithAnnotations($bar)
{
return 'Foo ' . $bar;
}
echo "foo = " . fooWithAnnotations("bar") . "\n";
// stop forp buffering
forp_end();
// get the stack as an array
$profileStack = forp_dump();
echo "forp stack = \n";
print_r($profileStack);
// Start profiler
forp_start();
my_complex_function();
// Stop profiler
forp_end();
// Get JSON and save it into file
forp_json_google_tracer("/tmp/output.json");