My experience using standalone Symfony Components

Agustín Houlgrave
2 min readApr 15, 2018

--

A while ago, I was not convinced about Symfony’s DI. Instead, I liked Zend Service Manager, but Symfony Forms as well, also ZendFramework won’t let you use Symfony Forms. So I just got a basic little project started that could enable you to get a routing library and wire it to any PSR-11 compiling container.
This allowed me to insert any component from Symfony, Aura, ZendFramework, etc.

Yay! I was able to pick any flavour I wanted to fit my needs! My first thoughts for a web application were:

So, everything went well. I could set up Symfony Forms with no problems, until I wanted to use Doctrine’s Form Types: These have dependencies on ManagerRegistry, which is the object than manages all the EntityManagers you have on your Symfony application. It’s responsible for getting the right manager for the right entity, etc.

In my application I had only an EntityManager, so I had lots of trouble, not only with the forms, but with Symfony’s validator as well. I guess that you can use a ManagerRegistry to wrap your EntityManager from the start of the project, but this is only needed for Symfony’s components integration, which are supposed to be standalone.

Ok, it wasn’t that bad, I could manage to integrate these. But then the Security Component was next: It’s binded to the full-stack framework at a very deep level and I decided it was not worth it: I had a framework-agnostic application! So in the end I went with Aura’s auth component, which was much easier to work with.

Symfony Components are easy to integrate, as long as their functionality is very isolated, like Serializer or Forms (with no doctrine extension). All the doctrine bridges need the ManagerRegistry, so take this in account when planning a project. Big components as the security one it’s not worth it. I know they’re supposed to be able to work outside the full-stack framework, but they’re also made to work with it as better as possible.

Link to my blog’s post: https://www.agustinhoulgrave.com/articles/2018-04/my-experience-using-standalone-symfony-components

--

--