1. Go to this page and download the library: Download magdv/liveprof 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/ */
oo\LiveProfiler\LiveProfiler::getInstance()->start();
// Code is here
oo\LiveProfiler\LiveProfiler::getInstance()
->setMode(\Badoo\LiveProfiler\LiveProfiler::MODE_API)
->setApiKey('70366397-97d6-41be-a83c-e9e649c824e1') // a key for guest
->useSimpleProfiler() // Use build-in profiler instead of XHProf or its forks
->setApp('Demo') // Some unique app name
->start();
// Code is here
// start a timer before each inportant method
\Badoo\LiveProfiler\SimpleProfiler::getInstance()->startTimer(__METHOD__); // any string can be used as a timer tag
// stop the timer before the end of the method
\Badoo\LiveProfiler\SimpleProfiler::getInstance()->endTimer(__METHOD__); // any string can be used as a timer tag
// Start profiling
\Badoo\LiveProfiler\LiveProfiler::getInstance()
->setMode(\Badoo\LiveProfiler\LiveProfiler::MODE_DB) // optional, MODE_DB - save profiles to db, MODE_FILES - save profiles to files, MODE_API - send profiles to http://liveprof.org/
->setConnectionString('mysql://db_user:db_password@db_mysql:3306/Profiler?charset=utf8') // optional, you can also set the connection url in the environment variable LIVE_PROFILER_CONNECTION_URL
->setPath('/app/data/') // optional, path to save profiles, you can also set the file path in the environment variable LIVE_PROFILER_PATH
->setApiKey('api_key') // optional, api key to send profiles and see demo, you can get it on http://liveprof.org/
->setApp('Site1') // optional, current app name to use one profiler in several apps, "Default" by default
->setLabel('users') // optional, the request name, by default the url path or script name in cli
->setDivider(700) // optional, profiling starts for 1 of 700 requests with the same app and label, 1000 by default
->setTotalDivider(7000) // optional, profiling starts for 1 of 7000 requests with forces label "All", 10000 by default
->setLogger($Logger) // optional, a custom logger implemented \Psr\Log\LoggerInterface
->setConnection($Connection) // optional, a custom instance of \Doctrine\DBAL\Connection if you can't use the connection url
->setDbTableName("liveproof") // optional, a custom db name, you can also set set table name int the env var LIVE_PROFILER_DB_TABLE_NAME
->setDataPacker($DatePacker) // optional, a class implemented \Badoo\LiveProfiler\DataPackerInterface to convert array into string
->setStartCallback($profiler_start_callback) // optional, set it if you use custom profiler
->setEndCallback($profiler_profiler_callback) // optional, set it if you use custom profiler
->useXhprof() // optional, force use xhprof as profiler
->useTidyWays() // optional, force use TidyWays as profiler
->useUprofiler() // optional, force use uprofiler as profiler
->useSimpleProfiler() // optional, force use internal profiler
->useXhprofSample() // optional, force use xhprof in sampling mode
->start();