Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference between Symfony and Silex

I would like to try Silex but i've some questions.

I know to use Symfony2 and i would like to know if Silex is very different of Symfony or it's the same thing (same operation, same code... ) ?

Moreover, Silex is recommanded for small PHP projects and Symfony for medium or big projects , it's true ?

like image 394
Alex L. Avatar asked Jun 29 '12 23:06

Alex L.


People also ask

What is the meaning of Symfony?

Symfony is a free and open-source PHP web application framework and a set of reusable PHP component libraries. It was published as free software on October 18, 2005, and released under the MIT license.

Is Symfony good framework?

The Symfony PHP framework is a well-organized, feature-rich PHP framework whose architecture paves the way for developers to build sustainable web applications in the easiest way possible which further enhances the users' experience.

Is Symfony a micro framework?

Symfony can be used as a microframework since Symfony 2.8. In fact, you can create fully working Symfony applications in a single file thanks to the MicroKernelTrait .

Is Symfony a MVC framework?

Symfony is an MVC framework written in PHP. Its structure is designed to get the best out of the MVC pattern, whilst maintaining great ease of use. Thanks to its versatility and configurability, symfony is suitable for all web application projects.


2 Answers

A few things worth noting:

  • Silex is based on the Symfony2 components, just like the Symfony2 framework is. As such, it can be considered an alternative user interface to the components (the user being a web developer).
  • Since they use the same basis, migration between them should be relatively easy.
  • Just like Symfony2, Silex is mostly a controller framework. It provides you with some structure, but the model and view parts are handled by third-party libraries (such as Twig or Doctrine).
  • Since your business logic should not be in your controllers anyway, if you separate that code out and keep your controllers light, the limiting factor in terms of project size will only be the amount of routes you have.

That said, Silex will not give you the bundles that Symfony2 has.

like image 61
igorw Avatar answered Sep 22 '22 05:09

igorw


Here are some interesting thoughts on when to use Silex (especially in the comments): https://web.archive.org/web/20160131151109/http://www.testically.org/2011/10/11/is-there-a-specific-situation-when-to-use-a-php-micro-framework-like-silex/

Silex itself is pretty bare, which means that if you want more then just routing and tests you will need to add specific features (DB, Twig ...) in form of Services. I recommend to take a look at some readymade Plates that provide you with this: https://github.com/lyrixx/Silex-Kitchen-Edition or https://github.com/ivoba/superleansilexplate (thats mine :))

Another point is that Silex has a probably lighter footprint than Symfony2, so if you need a smaller & faster site, Silex is worth a consideration.

like image 39
ivoba Avatar answered Sep 20 '22 05:09

ivoba