December 5-7, 2016
Vancouver, Canada

Blog: David Buchmann on Symfony

David Buchmann on Symfony

We interviewed David Buchmann, who is one of our speakers at ConFoo Vancouver 2016. His presentation is titled “Symfony Introduction”. David Buchmann works at Liip AG in Switzerland as project lead and Symfony coach. He is an open source enthusiast and active contributor to many PHP libraries. He lives in Switzerland.

What do you like most about Symfony?

There is a lot I like about Symfony. If I have to choose one single aspect, I pick "dependency injection." This architecture is also called "inversion of control." Without inversion of control, an object would instantiate objects it needs, or pull them from some service registry. Inversion of control instead provides the object the necessary dependencies.

This brings many benefits: clearly visible dependencies, re-using the same class in different configurations, and it simplifies unit testing a lot.

Can every type of application benefit from a framework?

This is a debatable question. My position is that all but the tiniest applications need some application infrastructure. A framework is a good starting point to provide that infrastructure. For rapid application development, Symfony provides a lot of default behaviour and PHPDOC annotation configuration to get started fast. For long projects, Symfony allows you to write your domain code without coupling it to the framework. A well designed framework like Symfony does not force choices (e.g. data persistence) on you.

Another aspect in favour of using a framework is the learning curve. If you do not use a defined framework, you will end up building infrastructure yourself, either from scratch or assembling components. Both options will make getting into the project harder for the people joining your team. A framework like Symfony provides good documentation. Except for really, really large projects, documentation will not be nearly as good as the framework documentation.

Can you use Symfony to write a REST API or a command-line tool?

Symfony itself is an HTTP framework built around the request-response cycle. The response can be in any format, from HTML over JSON or XML to sending binary data. The framework itself provides a serializer to translate objects into JSON or XML. You get many more features by using FOSRestBundle. There are even special distributions like Lakion Lionframe to get you started.

For command line tools, Symfony has the console component that handles command names and parameter handling. When using the framework, commands can be autodetected or explicitly registered. For pure command line applications, you can also use just symfony/console without the rest of the framework.

How does Symfony compare to other PHP frameworks?

I am not too familiar with other PHP frameworks. I will try to answer the question with highlighting some strong points of Symfony.

Symfony is both a framework for web application development and a collection of clean components that can be used on their own. The components are properly decoupled, allowing me to keep dependencies inside my code to a minimum. Reusable PHP libraries can use just the components they actually need.

Symfony is written in a clean, object-oriented approach. A lot of effort went into having clean code but being efficient at the same time. Human-readable configuration is translated into very efficient PHP code at deployment time to get a fast production application.

Symfony has an extensive documentation and an active community supporting developers. The community also provides high quality components for specific tasks.

Which resources would you recommend for learning Symfony?

The official documentation is quite good. The "Getting Started" tutorial gives you an idea of how to use Symfony. The rest of the documentation is more suitable for looking up specific questions.

SensioLabs, the main company behind Symfony, offers paid training both online or with live teachers. Knp University offers excellent video tutorials on Symfony (and PHP in general).

If you already work with Symfony but want to get deeper, I recommend the book "A year with Symfony" by Matthias Noback.

If you don't know Symfony yet, you should of course come to my talk at ConFoo Vancouver!

Don't forget to register for your nearest ConFoo conference and follow us on Twitter for more blog posts.

Vancouver 2016 sponsored by