Symfony2 dev notes

me vs. Symfony2, our ups and downs

Taming monolithic Symfony Bundles

Bundles are the basic building block of every Symfony app. With a recommended and adopted directory structure and auto-config, you can get loads of new features into your app just by adding one line to composer.json and another to your AppKernel.

You wonder how the creators of the bundles create such components? Sticking to a few rules will get you most of the way there. The rest is up to your coding skills!

read more »

Are we fast yet?

A quick overview of Symfony performance with proper configuration

What is the expected page load time of a Standard Edition Symfony application? How does it change in a production environment? How much time can be shaved off while not sacrificing whole components?

At foodpanda, we are prototyping a base for a new REST API and the following tests are executed against a skeleton which should be common for all requests, i.e. a Symfony secured Route (with the help of the FOSOAuthServerBundle) where the authentication provider makes a Redis query to verify an access token. The controller generates a JsonResponse by loading a result set from MySQL via DQL because unfortunately a good few milliseconds are added while booting the ORM. A few tricks are on the side of nginx and php-fpm, our web server setup, Apache won't be considered.

read more »

Saving the last matched route

Scenario

I'd like to redirect to the last request. For example, I have a form accesible from multiple pages and after submission I want to redirect the use to the page where he or she came from.

read more »

Loading Twig templates from an additional directory

The standard Twig loader in a Symfony app loads templates from the app/ directory and from Bundle resources. To load them from an additional location, it is possible to add a custom loader.

Since Twig uses a single loader, Twig_Loader_Chain is used to wrap the original loader and the new custom loader. The original loader is registered in the container as twig.loader, the custom loader will be a configured instance of Twig_Loader_Filesystem. The following configuration puts it altogether.

read more »