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

Mayur Pande
PLUS
Mayur Pande
Courses Plus Student 11,711 Points

Frameworks when to use them?

I am getting slightly confused as when to use framework, and also which ones. Should I use frameworks every time I am writing some PHP code? Or should I only use them on specific occasions. Also how would I know which framework to use, as there are so many out there, and I only have just learnt about the two we used in this course (composer and twig).

1 Answer

Kevin Korte
Kevin Korte
28,148 Points

Let me first clear clear something here, composer is a dependency manager, and twig is a template engine. Neither are really considered a "framework".

Composer is really beneficial on almost any project, with or without a framework as most projects will have dependencies. Twig can be beneficial on larger projects where views get more complicated. Twig is often used inside a framework, like Laravel.

Frameworks are fantastic if your app needs crud. (Create - Read - Update - Delete) features. A blog is a perfect candidate to use a framework. A basic, static php site would not need a framework. If you're database heavy, a framework can help tremendously here...if it's a small, light database than simple PDO will work.

As far as which frameworks to use, go with the flow. Currently Laravel, Lumen, and Slim are hot, and heavy development. That's what you want. I wouldn't personally recommend using a lesser none framework that it's in active development because of the possibilities of security vulnerabilities. Typically frameworks have a life cycle it seems. They're hot for a long time, and than the developer(s) loose interest in the project, and if the open source community decides to not carry it on, it kinda dies. You don't want a dead or dying framework.

The other is the weight of the framework. Lumen and Slim are lighter weight frameworks, with less features, for sites that don't need the everything and the kitchen sink. Laravel is a full stack framework with a lot of features, if that's what your site needs.

Mayur Pande
Mayur Pande
Courses Plus Student 11,711 Points

Thank you for the answer. From now on I will use Composer with my projects. After reading a bit more of the documentation on the composer site I think I need to sift through the packagist site to find out what packages can be of use to me in the future.

As for frameworks, I will probably start of using slim. As my projects are not that big at the moment (I am still trying to complete the PHP track!) then I will look into Laravel.