Silex

Articles on the Silex Framework, including tutorials and use cases.

Why you should use Silex for you next project

Almost a year ago now I worked on a contract where I was required to convert legacy PHP code, which had been written by a non-programmer. For the refactoring I first redesigned the database entirely, refactored any of the business logic out of any files which rendered content, and organised the entire structure. I created a simple router which was used to map simple urls to views which where rendered using an output buffer. I then set about finding an MVC framework to incrementally integrate with the refactored app.

After a few days of research, I chose Silex. Silex is very minimal and unopinionated. It also has very good documentation, including how to add Twig, the Doctrine DBAL (the ORM takes a bit of work) and many of the Symfony packages (Monolog, Swiftmailer, Session, Serializer, Assets and more). The best part was I could use Silex on it's own initially while moving my existing code to routes and controllers, and only then add a template engine and DB library. It also allows you to decide the structure yourself. As the project evolved I was able to rework anything that required it and add any library that could be PSR autoloaded easily.