The need for structure
The biggest problem with PHP is that it lacks any structure straight out of the box. Most amateur PHP programmers start out by writing raw PHP with no type of structure which is usually a pretty bad idea, the main reasons being security, organization of the code and wasted time. In order to deal with this you can provide your projects with a strong initial structure in the form of a framework.
What is a framework?
The ultimate goal of a framework is to allow you to do more in less time by providing you with strong basic building blocks. A framework is typically packaged with ways to neatly structure your project, a bunch of helper functions that help speed things up, basic levels of security such as sanitizing user input and a way to manage and process data. A great example of one of the core building blocks that usually comes with a PHP framework is a query builder. Usually writing raw SQL is unsafe because if you make a mistake you potentially create a security vulnerability, so instead query builders are created which writes the SQL for you. This makes it much safer because all you’re doing is calling functions and passing data as the parameters rather than writing raw SQL.
How does it differ to a CMS?
A CMS in its rawest form is usually also considered a framework, the big difference is that it usually comes with some sort of backend admin section which allows beginners or non-programmers to have more control over their website. The problem with this is that from an architectural point of view it takes away how much control you have because you have to now adhere to the structure of the CMS. If you picture the database, in a framework your database will be blank and you have complete control over how you structure it. In a CMS a lot of the stuff that makes the admin section work is stored in the database so you have to now adhere to the structure of the database of that CMS.
The image I always envision when I compare the two is that a framework is like giving somebody a strong set of tools to build a house. With those tools they can build the house to look however they want (although it will take a long time!). A CMS is like being given an empty house and having the power to customize it in any way you want. In terms of control you’re restricted to how the house was originally built but you can still add, remove or change anything about it if you really wanted to.
Working with frameworks will typically provide a better solution in the end but will usually take longer. Working with a CMS will allow you to create something very quickly, but the end product may not be the best solution.
The rise of Laravel
Laravel is an open source PHP framework that uses the MVC pattern (model view controller). Its first version was released 4 years ago in 2011 (as Laravel 1.0) and it’s now on Laravel 5.0.
Over the last 2 years there have been numerous amounts of online popularity contests on what is the best PHP framework available and since 2013 we’ve yet to see Laravel lose out in any of them. Over time the gap just seems to be getting bigger and bigger which makes us believe it’s undisputedly the most popular – and most likely the best PHP framework available right now. This of course is never black and white as the user’s needs can always sway one technology over another, but from a general perspective it’s safe to assume that right now Laravel is king of the PHP framework world.
The reason for its growth isn’t one particular thing as you’ll find most of the features in Laravel also exist in other frameworks. Instead it’s more to do with it being absolutely solid and a small build-up of tiny things that makes Laravel so good. Learning Laravel is very easy as it has a very strong documentation and an incredibly passionate community which makes it very attractive to new users. In comparison to other frameworks you can usually do more by typing less and it also has a very clean and elegant approach to most things. It’s very appealing for lesser experienced users but it also provides an enormous amount of power for the very advanced ones and that’s probably why it’s blew up in such a short period of time.
If you have any questions or needs for development using Laravel then get in touch.