Add Silex WebProfiler

This commit is contained in:
Romain Neutron
2013-02-11 15:07:15 +01:00
parent ef5de8d6f8
commit 11c5ae47f6
6 changed files with 92 additions and 18 deletions

View File

@@ -26,6 +26,7 @@
"phpexiftool/phpexiftool" : "~0.1.0", "phpexiftool/phpexiftool" : "~0.1.0",
"phpexiftool/exiftool" : "dev-master", "phpexiftool/exiftool" : "dev-master",
"silex/silex" : "1.0.x-dev@dev", "silex/silex" : "1.0.x-dev@dev",
"silex/web-profiler" : "1.0.x-dev@dev",
"swiftmailer/swiftmailer" : "~4.3.0", "swiftmailer/swiftmailer" : "~4.3.0",
"symfony/symfony" : "2.2.x-dev@dev", "symfony/symfony" : "2.2.x-dev@dev",
"tecnick.com/tcpdf" : "dev-master", "tecnick.com/tcpdf" : "dev-master",

56
composer.lock generated
View File

@@ -1,5 +1,5 @@
{ {
"hash": "fc5fa4c5fd4b320e0ff3c53ec0ad8705", "hash": "3214068afe9eec2f5219bcb246f8e0cf",
"packages": [ "packages": [
{ {
"name": "BadFaith/BadFaith", "name": "BadFaith/BadFaith",
@@ -1464,6 +1464,51 @@
"microframework" "microframework"
] ]
}, },
{
"name": "silex/web-profiler",
"version": "dev-master",
"target-dir": "Silex/Provider",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/Silex-WebProfiler",
"reference": "61207f087efbdc568d1d380f5d8ff54b4bbc1bab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sensiolabs/Silex-WebProfiler/zipball/61207f087efbdc568d1d380f5d8ff54b4bbc1bab",
"reference": "61207f087efbdc568d1d380f5d8ff54b4bbc1bab",
"shasum": ""
},
"require": {
"silex/silex": ">=1.0,<2.0",
"symfony/web-profiler-bundle": ">=2.2,<3.0",
"symfony/stopwatch": ">=2.2,<3.0"
},
"time": "2013-02-07 16:48:25",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Silex\\Provider\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "A WebProfiler for Silex",
"homepage": "http://silex.sensiolabs.org/"
},
{ {
"name": "swftools/swftools", "name": "swftools/swftools",
"version": "0.1.1", "version": "0.1.1",
@@ -1572,12 +1617,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "git://github.com/symfony/symfony.git", "url": "git://github.com/symfony/symfony.git",
"reference": "95ba9449e2d5e77bd945c1a0c611c30c4f0237c7" "reference": "f410931dd808cc7054599ba8fcb3d02e55b43584"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/95ba9449e2d5e77bd945c1a0c611c30c4f0237c7", "url": "https://api.github.com/repos/symfony/symfony/zipball/f410931dd808cc7054599ba8fcb3d02e55b43584",
"reference": "95ba9449e2d5e77bd945c1a0c611c30c4f0237c7", "reference": "f410931dd808cc7054599ba8fcb3d02e55b43584",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1629,7 +1674,7 @@
"doctrine/orm": ">=2.2,<3.0,>=2.2.3", "doctrine/orm": ">=2.2,<3.0,>=2.2.3",
"propel/propel1": "1.6.*" "propel/propel1": "1.6.*"
}, },
"time": "2013-02-11 11:43:49", "time": "2013-02-11 12:46:49",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
@@ -1931,6 +1976,7 @@
"neutron/silex-filesystem-provider": 20, "neutron/silex-filesystem-provider": 20,
"phpexiftool/exiftool": 20, "phpexiftool/exiftool": 20,
"silex/silex": 20, "silex/silex": 20,
"silex/web-profiler": 20,
"symfony/symfony": 20, "symfony/symfony": 20,
"tecnick.com/tcpdf": 20, "tecnick.com/tcpdf": 20,
"twig/extensions": 20, "twig/extensions": 20,

View File

@@ -1,6 +1,7 @@
rewrite ^/include/minify/([a-z]=.*) /include/minify/index.php?$1 last; rewrite ^/include/minify/([a-z]=.*) /include/minify/index.php?$1 last;
rewrite ^/admin/.*$ /index.php last; rewrite ^/admin/.*$ /index.php last;
rewrite ^/_profiler/.*$ /index.php last;
rewrite ^/lightbox.?$ /index.php last; rewrite ^/lightbox.?$ /index.php last;
rewrite ^/robots.txt$ /index.php last; rewrite ^/robots.txt$ /index.php last;
rewrite ^/feeds/.*$ /index.php last; rewrite ^/feeds/.*$ /index.php last;

View File

@@ -96,6 +96,8 @@ use Silex\Provider\TwigServiceProvider;
use Silex\Provider\SwiftmailerServiceProvider; use Silex\Provider\SwiftmailerServiceProvider;
use Silex\Provider\UrlGeneratorServiceProvider; use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\ValidatorServiceProvider; use Silex\Provider\ValidatorServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;
use Silex\Provider\WebProfilerServiceProvider;
use Unoconv\UnoconvServiceProvider; use Unoconv\UnoconvServiceProvider;
use XPDF\PdfToText; use XPDF\PdfToText;
use XPDF\XPDFServiceProvider; use XPDF\XPDFServiceProvider;
@@ -182,6 +184,10 @@ class Application extends SilexApplication
$this->register(new MediaAlchemystServiceProvider()); $this->register(new MediaAlchemystServiceProvider());
$this->register(new MediaVorusServiceProvider()); $this->register(new MediaVorusServiceProvider());
$this->register(new MonologServiceProvider()); $this->register(new MonologServiceProvider());
$this['monolog.name'] = 'Phraseanet logger';
$this['monolog.handler'] = $this->share(function () {
return new NullHandler();
});
$this->register(new MP4BoxServiceProvider()); $this->register(new MP4BoxServiceProvider());
$this->register(new NotificationDelivererServiceProvider()); $this->register(new NotificationDelivererServiceProvider());
$this->register(new ORMServiceProvider()); $this->register(new ORMServiceProvider());
@@ -191,13 +197,29 @@ class Application extends SilexApplication
$this->register(new SessionServiceProvider(), array( $this->register(new SessionServiceProvider(), array(
'session.test' => $this->getEnvironment() == 'test' 'session.test' => $this->getEnvironment() == 'test'
)); ));
$this->register(new ServiceControllerServiceProvider());
$this->register(new SwiftmailerServiceProvider());
$this->register(new TaskManagerServiceProvider()); $this->register(new TaskManagerServiceProvider());
$this->register(new TwigServiceProvider(), array(
'twig.options' => array(
'cache' => realpath(__DIR__ . '/../../../../../../tmp/cache_twig/'),
)
));
$this->setupTwig();
$this->register(new UnoconvServiceProvider()); $this->register(new UnoconvServiceProvider());
$this->register(new UrlGeneratorServiceProvider()); $this->register(new UrlGeneratorServiceProvider());
$this->register(new UnicodeServiceProvider()); $this->register(new UnicodeServiceProvider());
$this->register(new ValidatorServiceProvider()); $this->register(new ValidatorServiceProvider());
if ('dev' === $this->environment) {
$this->register($p = new WebProfilerServiceProvider(), array(
'profiler.cache_dir' => __DIR__ . '/../../../cache/profiler',
));
$this->mount('/_profiler', $p);
}
$this->register(new XPDFServiceProvider()); $this->register(new XPDFServiceProvider());
$this->register(new SwiftmailerServiceProvider());
$this['swiftmailer.transport'] = $this->share(function ($app) { $this['swiftmailer.transport'] = $this->share(function ($app) {
@@ -266,10 +288,6 @@ class Application extends SilexApplication
throw new \RuntimeException('No Imagine driver available'); throw new \RuntimeException('No Imagine driver available');
}); });
$this['monolog.name'] = 'Phraseanet logger';
$this['monolog.handler'] = $this->share(function () {
return new NullHandler();
});
$app = $this; $app = $this;
$this['phraseanet.logger'] = $this->protect(function($databox) use ($app) { $this['phraseanet.logger'] = $this->protect(function($databox) use ($app) {
@@ -296,14 +314,6 @@ class Application extends SilexApplication
}) })
); );
$this->register(new TwigServiceProvider(), array(
'twig.options' => array(
'cache' => realpath(__DIR__ . '/../../../../../../tmp/cache_twig/'),
)
));
$this->setupTwig();
$this['dispatcher']->addListener(KernelEvents::REQUEST, array($this, 'addLocale'), 255); $this['dispatcher']->addListener(KernelEvents::REQUEST, array($this, 'addLocale'), 255);
$this['dispatcher']->addListener(KernelEvents::REQUEST, array($this, 'initSession'), 254); $this['dispatcher']->addListener(KernelEvents::REQUEST, array($this, 'initSession'), 254);
$this['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'addUTF8Charset'), -128); $this['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'addUTF8Charset'), -128);

View File

@@ -172,6 +172,21 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract
$this->assertEquals('123456', $sessionId); $this->assertEquals('123456', $sessionId);
} }
public function testWebProfilerDisableByDefault()
{
$app = new Application('prod');
$this->assertFalse(isset($app['profiler']));
$app = new Application('test');
$this->assertFalse(isset($app['profiler']));
}
public function testWebProfilerEnableInDevMode()
{
$app = new Application('dev');
$this->assertTrue(isset($app['profiler']));
}
private function getAppThatReturnLocale() private function getAppThatReturnLocale()
{ {
$app = new Application('test'); $app = new Application('test');

View File

@@ -2,6 +2,7 @@
RewriteEngine on RewriteEngine on
RewriteRule ^include/minify/([a-z]=.*) /include/minify/index.php$1 [L,NE] RewriteRule ^include/minify/([a-z]=.*) /include/minify/index.php$1 [L,NE]
RewriteRule ^_profiler/.*$ /index.php [L]
RewriteRule ^lightbox/.*$ /index.php [L] RewriteRule ^lightbox/.*$ /index.php [L]
RewriteRule ^admin/.*$ /index.php [L] RewriteRule ^admin/.*$ /index.php [L]
RewriteRule ^permalink/.*$ /index.php [L] RewriteRule ^permalink/.*$ /index.php [L]