Example #1
0
<?php

error_reporting(-1);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
try {
    if (!defined('DIRS')) {
        define('DIRS', DIRECTORY_SEPARATOR);
    }
    if (!defined('ROOTFULLPATH')) {
        define('ROOTFULLPATH', dirname(__DIR__));
    }
    if (!defined('TRACK')) {
        define('TRACK', TRUE);
    }
    require_once ROOTFULLPATH . '/vendor/autoload.php';
    $profiler = new \Fabfuel\Prophiler\Profiler();
    $bootstrap = $profiler->start('Bootstrap', ['lorem' => 'ipsum'], 'Application');
    require_once 'bootstrap/Load.php';
    $di = new \Phalcon\DI\FactoryDefault();
    $di->setShared('profiler', $profiler);
    $Load = new Load($di);
    $app = $Load->run();
    $profiler->stop($bootstrap);
    echo $app->handle()->getContent();
} catch (\Phalcon\Exception $e) {
    echo $e->getMessage();
}
$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
//echo $toolbar->render();
        style="max-width:100%;"></a>
    <a href="https://scrutinizer-ci.com/g/fabfuel/prophiler/build-status/develop"><img
        src="https://scrutinizer-ci.com/g/fabfuel/prophiler/badges/build.png?b=develop"
        alt="Build Status"
        data-canonical-src="https://scrutinizer-ci.com/g/fabfuel/prophiler/badges/build.png?b=develop"
        style="max-width:100%;"></a>
</div>

</body>
</html>

<?php 
require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
require __DIR__ . '/DataCollector/User.php';
require __DIR__ . '/DataCollector/Request.php';
$profiler = new \Fabfuel\Prophiler\Profiler();
$logger = new \Fabfuel\Prophiler\Adapter\Psr\Log\Logger($profiler);
$multiplicator = 20;
$wait = function ($time) use($multiplicator) {
    return $time * rand($multiplicator * 0.8, $multiplicator * 1.2);
};
$bootstrap = $profiler->start('Bootstrap', ['lorem' => 'ipsum'], 'Application');
usleep($wait(50));
$profiler->stop($bootstrap);
$logger->info('Bootstrap has finished', ['some' => 'context']);
$bootstrap = $profiler->start('Session::load', ['lorem' => 'ipsum'], 'Sessions');
usleep($wait(45));
$profiler->stop($bootstrap);
$dispatcher = $profiler->start('Dispatcher', ['abc' => '123', 'foobar' => true], 'Dispatcher');
usleep($wait(25));
$logger->warning('Not everything ready to go', ['some' => 'context']);