Symfony and named ParamConverters

Symfony’s ParamConverter is a common way to transform some GET param to an entity before your controllers action.
This happens most of the time via type hinting and priority detection kinda magic in the background.
But as magic is often obscure sometimes you need a bit of explicitness.

F.e. when you have more and different ParamConverter per entity you want to name them explicitly.
Then you can use named ParamConverters.

In the documentation this issue is a bit fragmented, so here is the compact version:
Continue reading “Symfony and named ParamConverters”

Caching Data in Symfony2

Symfony2 has a great Caching Layer based on its HTTP Cache. But this aims mainly on caching the views.

In some apps however you need to cache data behind the scenes, f.e. responses from API calls or custom objects sets.
Symfony2 itself doesnt have such a functionality on first sight (symfony2 doesnt, but Doctrine, see below) and so I searched for one and first found a bundle which utilize the Zend Cache lib:
https://github.com/KnpLabs/KnpZendCacheBundle

This worked well but as discussed here(https://github.com/KnpLabs/KnpZendCacheBundle/issues/2) this adds dependencies to your Symfony2 project. This is actually not necessary since Doctrine/Commons is almost always part of your Symfony2 distribution and the Doctrine/Commons provides a Cache Layer as well.
A very good one, indeed.

So if you need to cache data use Doctrine/Commons.
Continue reading “Caching Data in Symfony2”