Skip to content

Commit 81de492

Browse files
fbourigaultNyholm
authored andcommitted
fix profiler display when using in a symfony/flex project (#196)
1 parent 81227a5 commit 81de492

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## unreleased
6+
7+
### Fixed
8+
9+
- Display of the profiler panel when used in a symfony/flex project.
10+
511
## 1.7.0 - 2017-07-25
612

713
### Added

Resources/config/data-collector.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</service>
1515

1616
<service id="httplug.collector.collector" class="Http\HttplugBundle\Collector\Collector" public="false">
17-
<tag name="data_collector" template="HttplugBundle::webprofiler.html.twig" priority="200" id="httplug"/>
17+
<tag name="data_collector" template="@Httplug/webprofiler.html.twig" priority="200" id="httplug"/>
1818
</service>
1919

2020
<service id="httplug.plugin.stack" class="Http\HttplugBundle\Collector\StackPlugin" public="false" abstract="true">

Tests/Functional/ProfilerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Http\HttplugBundle\Tests\Functional;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
class ProfilerTest extends WebTestCase
8+
{
9+
public function testShowProfiler()
10+
{
11+
$client = static::createClient();
12+
13+
//Browse any page to get a profile
14+
$client->request('GET', '/');
15+
16+
$crawler = $client->request('GET', '/_profiler/latest?panel=httplug');
17+
$title = $crawler->filterXPath('//*[@id="collector-content"]/h2');
18+
19+
$this->assertCount(1, $title);
20+
$this->assertEquals('HTTPlug', $title->html());
21+
}
22+
}

Tests/Resources/app/AppKernel.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?php
22

3+
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
34
use Symfony\Component\Config\Loader\LoaderInterface;
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\HttpFoundation\Response;
47
use Symfony\Component\HttpKernel\Kernel;
8+
use Symfony\Component\Routing\RouteCollectionBuilder;
59

610
class AppKernel extends Kernel
711
{
12+
use MicroKernelTrait;
13+
814
/**
915
* {@inheritdoc}
1016
*/
@@ -26,14 +32,24 @@ public function registerBundles()
2632
/**
2733
* {@inheritdoc}
2834
*/
29-
public function registerContainerConfiguration(LoaderInterface $loader)
35+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
3036
{
3137
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
3238
if ($this->isDebug()) {
3339
$loader->load(__DIR__.'/config/config_debug.yml');
3440
}
3541
}
3642

43+
/**
44+
* {@inheritdoc}
45+
*/
46+
protected function configureRoutes(RouteCollectionBuilder $routes)
47+
{
48+
$routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt');
49+
$routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler');
50+
$routes->add('/', 'kernel:indexAction');
51+
}
52+
3753
/**
3854
* {@inheritdoc}
3955
*/
@@ -57,4 +73,9 @@ protected function getContainerBaseClass()
5773
{
5874
return '\PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer';
5975
}
76+
77+
public function indexAction()
78+
{
79+
return new Response();
80+
}
6081
}

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"symfony/framework-bundle": "^2.8 || ^3.0",
2929
"php-http/message": "^1.4",
3030
"php-http/discovery": "^1.0",
31-
"twig/twig": "^1.18 || ^2.0"
31+
"twig/twig": "^1.18 || ^2.0",
32+
"symfony/asset": "^2.8 || ^3.0"
3233
},
3334
"require-dev": {
3435
"phpunit/phpunit": "^4.5 || ^5.4",
@@ -45,6 +46,8 @@
4546
"symfony/web-profiler-bundle": "^2.8 || ^3.0",
4647
"symfony/finder": "^2.7 || ^3.0",
4748
"symfony/cache": "^3.1",
49+
"symfony/browser-kit": "^2.8 || ^3.0",
50+
"symfony/dom-crawler": "^2.8 || ^3.0",
4851
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
4952
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
5053
"nyholm/nsa": "^1.1"

0 commit comments

Comments
 (0)