Provide PinbaBundle functionality for Silex
composer require bi0r0b0t/silex-pinba-provider
or
Require the bundle in your composer.json
file:
{
"require": {
"bi0r0b0t/silex-pinba-provider": "~1.0",
}
}
Through Composer as bi0r0b0t/silex-pinba-provider .
Require the bundle in your composer.json
file:
{
"require": {
"bi0r0b0t/silex-pinba-provider": "~0.1",
}
}
Important! Register the bundle in prod
environment after TwigServiceProvider and DoctrineServiceProvider:
/**
* @var $app Silex\Application
*/
$app->register(new SilexPinbaProvider\SilexPinbaProvider()
Examples based on dflydev/doctrine-orm-service-provider
/**
* @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;
});
/**
* @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;
});
/**
* @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();
}