Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

syedtalal
syedtalal
4,972 Points

Best PHP Microframework?

There are tons of options like Silex, Aura, Slim. Which one is the best in terms of providing a robust enough MVC structure, functionality and getting out of the way of doing actual work?

11 Answers

Hello Syed Talal

There are may options out there for micro frame works, I have personally tried out two of them on some small projects. I am currently favoring the one that Guilherme Uhelski mentioned, Silex. Here is a short video about Silex.

The project is very well documented and has a good community of folks that have solved a lot of pitfalls that you may stumble upon. We will be working more with Silex in the future as well as working on a course using a full stack PHP framework.

I hope that this helps you out. Cheers, Hampton

Relevant Links:

Silex

Symfony

Fabien Potencier, Co-Creator of Silex

Great video! I'm glad you're doing this.

Robert Russell
Robert Russell
8,958 Points

I don't know about micro, but codeigniter has a pretty small footprint and is my FAV http://ellislab.com/codeigniter

Me too! Hope it'll get new host soon.

what a nice video, i would love to see some course with this framework on teamtreehouse. a site like twitter. they made one one ruby on rails track.

Guilherme Uhelski
Guilherme Uhelski
2,801 Points

I would say Silex, since it's small and simple enough to not get in your way, but robust and extensible (you can use Symfony2 components). It's also interesting the way it explores (the good) PHP features, and good practices, if you are in for some learning you can also check this series of articles from it's creator: http://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the-symfony2-components-part-1

Thank you so much for posting this video, I was just looking for a similar PHP framework like Sinatra, but I found slim first and it was not the real thing. :) Silex is much more similar to Sinatra, and the documentation is well detailed.

what a nice video, i would love to see some course with this framework on teamtreehouse. a site like twitter. they made one one ruby on rails track.

Iban Dominguez
Iban Dominguez
17,973 Points

Great video! can't wait for more php courses!

Thanks for this. I've been wanting to compile a list of frameworks I'd use for different purposes. This one looks like it might be good if I were to build a web api back-end. I already have a micro-framework in mind for Python but I didn't have anything for PHP yet.

really good video :)

Charles Coop
Charles Coop
3,045 Points

I have a couple general questions regarding Silex and micro-frameworks in general. What is the difference between a micro-framework, a lightweight framework (e.g., CodeIgniter), and a full-stack framework, like CakePHP or Laravel? When would you use one over another (not to cause a debate over which framework is better, rather, just to understand what size/level of the framework to incorporate into a project)? Is it based solely on the overall size of the application that you are trying to build? Why not just take a full-stack framework and use only the features you need?

Also, can someone please briefly walk me through the example shown in the video? Would there have been an appreciable difference in the amount of code involved without the use of Silex?

My apologies for asking so many questions. Thanks!

The main difference, according to my experience, between a regular MVC and a micro framework, is that if the website does not use database, or does not have a complex structure, then you can go ahead and use a micro framework because: 1.) It is easier to develop small apps with. 2.) It is faster. 3.) And only has the essential components needed for a small site.

And if you are creating a one page app or a really simple website then you will anyway not use all the complex stuff which is built into a regular MVC framework.

A micro framework in some cases is even useful if you are making the website for a company which starts out small but have future development in mind. If you are using Sinatra for example you can mount the app into a rails framework later on. That way you get into a habit that you use a framework even in case of small sites, so you can extend the application later as necessary. If my assumption is correct then Silex can do the same, only with Symphony.

And if you are wondering what does it takes to in order to achieve the same with PHP code only, then go ahead and check out the source code, as that is the best way to find out how things work.

P.S.: From my point of view a micro-framework and a lightweight framework is completely the same.

This is true and I agree with you on all the points above, I recently created my own site for freelancing which was only five pages or so, I originally built it in Laravel using what I know best, I also used a bunch of design patterns for various things. Then I realised this was way over the top, but rather than using a PHP micro-framework I decided to use a static site generator (Jekyll). Not 100% sure where a micro-framework would fit into my workflow, for me it's either simple enough for Jekyll or complex enough to warrant using Laravel.

The benefit of Jekyll that it is faster than anything else in ruby, even faster than Sinatra, the only downside is that it does not support databases, of course there are workarounds for that also. Also if you check this treehouse video: http://teamtreehouse.com/library/mozcon-2013/win-through-optimization-and-testing then you can see from the example that in case of a high traffic site, load of the page was only two seconds, in the first second all the text and in the second the images. So it is worth being a Jekyll guru and have huge performance benefits. And to be honest no one recommends to build a database driven application with a micro framework, but it is still worth it if you are working with minimal amount of data and you need a fast application.

Gareth Redfern
Gareth Redfern
36,217 Points

Would love to see a full Deep dive on using this, I know there is the Workshop which is a brilliant intro but I think this would make a great in depth course linked to the OOP training.