bi0r0b0t / silex-pinba-provider
Provide PinbaBundle for Silex
1.0.7
2018-06-20 14:29 UTC
Requires
- doctrine/dbal: ~2.2
- intaro/pinba-bundle: ~0.4.2
- silex/silex: ~2.0
- twig/twig: ^2.0
Requires (Dev)
- gggeek/pinba_php: dev-master#d23c3725a19d53a6f98f91673d73e8f685f6f3d7
- misterion/pinba-phpdoc: dev-master
- phpunit/phpunit: ^6.4
README
Provide PinbaBundle functionality for Silex
Installation
For Silex 2.0
composer require bi0r0b0t/silex-pinba-provider
or
Require the bundle in your composer.json
file:
{ "require": { "bi0r0b0t/silex-pinba-provider": "~1.0", } }
For Silex 1.0
Through Composer as bi0r0b0t/silex-pinba-provider .
Require the bundle in your composer.json
file:
{ "require": { "bi0r0b0t/silex-pinba-provider": "~0.1", } }
Register
Important! Register the bundle in prod
environment after TwigServiceProvider and DoctrineServiceProvider:
/** * @var $app Silex\Application */ $app->register(new SilexPinbaProvider\SilexPinbaProvider()
Using with Doctrine ORM
Examples based on dflydev/doctrine-orm-service-provider
Collecting Filesystem metrics
/** * @var $app Silex\Application */ $app['orm.cache.factory.filesystem'] = $app->protect(function($cacheOptions) use ($app) { if (empty($cacheOptions['path'])) { throw new \RuntimeException('FilesystemCache path not defined'); } $cache = new SilexPinbaProvider\Cache\Filesystem($cacheOptions['path']); $cache->setStopwatch($app['intaro_pinba.stopwatch']); return $cache; });
Collecting Memcache metrics
/** * @var $app Silex\Application */ $app['orm.cache.factory.backing_memcache'] = $app->protect(function() use ($app) { $cache = new Intaro\PinbaBundle\Cache\Memcache(); $cache->setStopwatch($app['intaro_pinba.stopwatch']); return $cache; });
Using with console
/** * @var $console Symfony\Component\Console\Application * @var $app Silex\Application */ if (function_exists('pinba_script_name_set')) { pinba_script_name_set('console'); $input = new Symfony\Component\Console\Input\ArgvInput(); $timer = pinba_timer_start(array( 'server' => $app['intaro_pinba.server.name'], 'group' => 'console::run', 'command' => $input->getFirstArgument(), )); $res = $console->run($input); pinba_timer_stop($timer); return $res; } else { return $console->run(); }