Debugging Silex applications just got fun

Fabien Potencier

February 07, 2013

What is the difference between a full-stack framework and a micro framework? To me, this is not about the amount of code, but more about how you build an application and how you structure it. Symfony and Silex share a lot of code (Silex specific code being quite minimal), but developing an application with one or the other is a totally different experience. And choosing between the two really depends on your needs, the application you want to create, the skills of your team, etc...

One of the big advantages of both Symfony and Silex is that they are based on the Symfony HttpKernel component. Why is it an advantage? One of the reasons is the standardization of the HTTP dialog between the client and the application server and the standardization of the HTTP messages via the HttpFoundation component; that makes all applications using it easily interoperable (like Drupal, eZPublish, Laravel, and many others).

But handling HTTP requests with the Symfony HttpKernel also gives you a lot of free and optional features like a built-in reverse proxy written in PHP, easy handling of ESI and Hincludes (via the Fragment sub-framework), or the gorgeous Symfony web profiler:

The timeline panel in the Symfony Web Profiler

I've just published a Silex provider that integrates the Symfony web profiler into Silex.

To get started faster, create a new application via my Silex Skeleton, where the profiler is already integrated and available when in the development environment:

composer create-project fabpot/silex-skeleton somewhere/ 1.0.x-dev

Igor recently wrote about HttpKernel and HttpFoundation on his blog... interesting read.


gravatar ragtek  — February 07, 2013 17:05   #1
Nice improvement:)
gravatar Wouter De Jong  — February 07, 2013 17:52   #2
This is really great!

That´s why I love Symfony: Almost all feature can be used everywhere, in a Framework, CMS, CMF, micro-framework, ect.
gravatar Ludovic Fleury  — February 07, 2013 18:22   #3
Oh-My-God, this is just really awesome Fabien, thanks much. As a silex-lover I couldn't expect a greater feature
gravatar Amitay Horwitz  — February 08, 2013 09:54   #4
gravatar Bruno Chalopin  — February 08, 2013 13:47   #5
Great addition but unusable for now because of the "minimum-stability": "dev" composer restriction :-/
gravatar Boabramah Ernest  — February 09, 2013 03:31   #6
I currently use components like the HttpFoundation, Event Dispatcher, Dependency Injection Container, ClassLoader in my project. Is it possible to intergrate the web profiler into my project just like the other components?. Thanks for the great work Fabien.
gravatar Luis Cordova  — February 09, 2013 05:14   #7
nice, good news, silex is almost like an excuse to read inner code more in depth

gravatar Kevin Levie  — March 08, 2013 12:04   #8
Looks like a great feature! I unfortunately can't get it to work...
I'm getting Twig errors for all Web Profiler templates:

Twig_Error_Loader: Template "@WebProfiler/Profiler/toolbar_js.html.twig" is not defined ().
Twig_Error_Loader: Template "@WebProfiler/Profiler/results.html.twig" is not defined ().

I'm not exactly sure how Twig is supposed to resolve these @WebProfiler templates. I tried fiddling around with Twig settings and installing different dev versions through composer, but that doesn't make any difference. The files are correctly in place at symfony/web-profiler-bundle/... etc.

Do any of you guys have an idea how to solve this?
gravatar Dan  — March 11, 2013 01:39   #9
Kevin Levie, I've got the same error. I have no idea why it's giving me errors.

gravatar Kevin Levie  — March 20, 2013 12:30   #10
@Dan, in the end I managed to get the profiler bar to work (for now) by adding this to my Twig initialisation (and making sure the cache was empty):

$webProfilerPath = $dir . '/vendor/symfony/web-profiler-bundle/Symfony/Bundle/WebProfilerBundle/Resources/views';
$app['twig.loader.filesystem']->addPath($webProfilerPath, 'WebProfiler');