Work with us

To contact our team enter your details below and we will be in touch as soon as possible.

Download

To download this, please enter your email address below

Menu

20

Jul

PHP frameworks: comparing Laravel and Symfony

PHP frameworks: comparing Laravel and Symfony
In a previous feature, we introduced the idea of using a framework alongside PHP in order to leverage countless advantages and benefits to your development project. We mentioned that two of the most popular frameworks for PHP right now are named Laravel and Symfony.

Just to recap briefly, by using a framework in a software development project, developers can potentially save significant amounts of time by building projects that reuse key components and approaches that a huge number of other developers have created and tested. This results in less problems with bugs and issues, and provides more opportunity to focus on the implementation and system design aspects of the project to better ensure that these important areas are covered very well. It also makes it easier for us to stay up to date with the best way to approach certain areas, for example security.

At the time of writing, Laravel version 6 is available, and Symfony is at version 5, with version 6 not far around the corner. This is a very good thing, with so many major release versions under their belt, both frameworks have already been through a significant number of changes, optimisations, and redesigns to ensure that they are always promoting and delivering a secure, performant and robust platform on top of which to develop great software.

On the subject of different versions, both Laravel and Symfony promote the use of what their respective development teams call ‘Long Term Support’ (LTS) releases of the frameworks. These releases are guaranteed to offer support and security fixes for multiple years, so everybody can be safe in the knowledge that some big breaking change isn’t going to suddenly appear in the short term and require significant amounts of re-working.

Both of these popular frameworks provide the developer with a fantastic set of features, and as different as they are, there are some surprising similarities that are interesting to talk about. One fascinating fact, is that even though Laravel itself is a Framework for PHP, it is itself actually built on top of Symphony! That may sound strange, but when it comes to solving common problems in software, tried and tested is a great way to go. Therefore the core aspects of Laravel being built on top of Symphony mean that it is:

  1. Easier for the Laravel development team to build their offering, because they can leverage all of Symfony’s benefits in their work;
  2. Because these Frameworks share many components, it makes it more familiar and therefore easier when it comes to producing core areas of development.

That said, there are as many differences as there are similarities, from the way a project is structured, to how you talk to the database (a persistent store of information that most software projects will need) and how you add new elements of functionality and data to your project. We’ve tried to cover some of the differences below.


Laravel – Key Facts

  • First released in 2011
  • Originally Developed by Taylor Otwell
  • Still guided and developed according to Taylor’s preferences and vision, along with a wider team of contributors
  • Uses a system called ‘Eloquent’ for interacting with a database
  • Uses it’s own system for funning custom commands, named ‘Artisan’
  • Best suited for use on small to medium scale projects, especially backend API development
  • Great for Rapid prototyping and as a way for developers to ‘get things done quickly’, but only through learning all of the shortcuts.
  • Focused on simplifying code and ‘hiding’ complexity away by presenting it’s own shortcuts and conventions that need to be learned
  • Closely linked to the ‘Vue’ front end framework, and designed to provide a good backend solution to a vue project
  • Expects projects to be approached and structured in a very ‘Laravel’ way

Symfony – Key facts

  • First released in 2005
  • Original Developed by Fabien Potencier, and Sponsored by Sensio Labs
  • Inspired by the ‘Spring’ framework, which is very popular among Java developers.
  • Still guided and developed according to Taylor’s preferences and vision, along with a wider team of contributors
  • Uses a popular and widely supported system called ‘Doctrine’ for interacting with a database (after versions later than v1 of Symfony, which used ‘Propel’)
  • Uses it’s own console system, simply known as ‘the console’ for running commands
  • Well suited to all scales of project from small applications to enterprise grade APIs and lager projects.
  • Easier for developers to get to grips with
  • Closer to native PHP, and less ‘magic’ in terms of what it’s like to work with
  • Less ‘opinionated’ about how code should be approached than Laravel
  • Uses the TWIG templating engine as a front end, visual layer (optionally)
  • Very flexible around structure and approach, you really can use Symfony in whatever ways you can think of!

Laravel and Symfony: Which is better?

On the Wikipedia page about symfony, it’s goals are stated as follows:

Symfony aims to speed up the creation and maintenance of web applications and to replace repetitive coding tasks. It’s also aimed at building robust applications in an enterprise context, and aims to give developers full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match enterprise development guidelines, Symfony is bundled with additional tools to help developers test, debug and document projects.

Meanwhile, Laravel is described on its Wikipedia page as follows:

Taylor Otwell created Laravel as an attempt to provide a more advanced alternative to the CodeIgniter framework, which did not provide certain features such as built-in support for user authentication and authorization.

At Kolodo Agency, we will sometimes advocate one of these two frameworks over the other given the needs of any one individual project. They are both great frameworks at the end of the day, and been a great help to the industry as a whole with developers everywhere ranging from those within small business scenarios, right up to huge multinational enterprise level solutions.

Symfony particularly (given that it underpins the larval framework, too) has helped PHP to stay right up there as a contemporary, viable, secure and robust platform to be building great applications upon.

We would love any opportunity to talk to you or your technical teams further about the pros and cons of these PHP frameworks and how we can leverage their features to make your project, and the experience of having it created or improved, so much quicker, easier and cheaper than it would be without them.