Before choosing a framework, we have to answer three important questions. What is the PHP framework, what is it used for and whether we really need it.
What is the PHP framework?
Framework is a combined collection of tools, libraries and scripts, conditioned by a single programming convention to standardize, speed up work and solve basic complications for a developer.
If PHP frameworks hadn’t existed, with each separate project, we would have to worry about advanced and error-free database support, friendly URLs, session management, sending e-mails and hundreds of other smaller or larger formalities that are universal and should not take our time. We do not have to worry about it at all because of the ready-made projects called frameworks. We have time to focus on more important issues, and not on repetitive tasks which we would not do as well as the entire community that is constantly using and improving the framework.
What PHP frameworks are available?
Since we already know the advantages of using frameworks, it is worth-thinking about which one to choose for our job. If we want to experiment and have time, it is worth knowing the basics of each and choose the one that suits us best. However, usually we do not have so much free time and it will be better to know one framework, but proficiently.
Let’s analyze the pros and cons of the most popular PHP frameworks, let's find one that is the best to start our adventure with and which will best meet our needs.
All solutions the frameworks in short:
The most popular PHP framwork at the moment, even though it was created only in 2011. Around Laravel emerged a huge ecosystem of services, solutions and training materials (such as a huge compendium of knowledge — Laracasts website — we highly recommend it to all PHP programmers, not only those using Laravel).
Laravel has its own ORM — Eloquent, its own template system — Blade, the vastness of ready-made out-of-the-box solutions, among others authorization, cache support, multiple file systems, queues, etc.
One of the most popular PHP frameworks, consisting of many independent modules. There are quite a few other solutions based on these modules, for example Drupal, the phpBB forum, and Laravel. The use of modules from Symfony allows you to speed up your work in every aspect of the work on the website.
Symfony has also gathered around a huge community with a large number of successful implementations of large scale services.
Codelgniter is a quite light project, occupying barely 2MB, with a simple configuration and very good documentation. It was created in 2006, but it did not develop at the same pace as other frameworks.
At some point there was a risk that the project would die, however, it has been developing rapidly for 2 years.
Codelgniter does not use many solutions, which were in PHP 5.6 and PHP 7, thanks to it is not compatible even with version 5.2.4 (which we do not recommend), but it is an advantage when there's no other way and we must use servers shared with an old configuration that cannot be updated. But besides, it is very fast and allows a lot of freedom in programming style (which is an advantage, as well as a disadvantage).
Yii is a framework that focuses on speed and simplicity. Like other frameworks, it allows you to generate many objects/files for us and allows you to automate basic tasks such as cache, authorization, tests, translations, etc.
It is strongly integrated with jQuery, thanks to which it allows unique integration of front-end and back-end by Ajax.
Zend is a complex, but also complicated framework. It has a lot of facilities like built-in drag&drop editor or online code debugging. The main plus is its performance on large projects.
However, due to the amount of configurations and the possibilities of efficiency improvements, it is certainly not the best solution to start with.
CakePHP is quite an old solution, but still very popular. It has very good documentation, it is easy to use, but also uses a lot of modern PHP concepts such as namespaces.
A very interesting solution is Phalcon, which was created in 2012 and unlike the rest of the frameworks, it was written in C and C ++ to achieve the highest performance (PHP itself is written in C ++, although PHP7 in some tests is slightly faster than pure C ++). This also affects the type of code, which is more low-level, devoid of abstraction, which reduces the number of resources used, but also the readability of the code.
After all, if speed is our priority, it is certainly an interesting solution, but in the context of API (where performance is the key), there are solutions that may be more appropriate.
Slim is a micro framework, with a minimum of facilities, which primarily has speed and efficiency as its main goals. The main application is a REST-based API (abbreviated as network services that perform operations and recovers data based on HTTP-based requests), where you do not need many solutions used in complex websites.
Slim has, of course, the basics of caching, routing, session security and cookies. In addition to the API, you can also build fully-fledged websites, but in comparison to other frameworks, many improvements are not available, due to its nature.
Other examples of microframeworks are:
• Lumen (based on Laravel)
• Silex (based on Symfony)
In which case, what PHP framework to choose?
In order to answer this question and be able to choose the right framework one should answer the question what is important to us, and what we care about and what a good framework should characterize.
All the above-mentioned solutions have a similar set of functionalities and ready-made libraries. They differ in the size of the community, the available external libraries, the speed of development and the number of job offers on the market.
If we look at these requirements, we will have several favorites:
• Laravel - the most popular framework in the world, very pleasant syntax, very easy to learn, stable, modern, with a large and committed community.
• Symfony - Very popular, most of the job offers for PHP developers still concern Symfony (at least in Poland).
• Codelgniter - very simple, ideally suited for learning and for simple projects, great to start the adventure with frameworks to get to know the MVC pattern and basic concepts.
We learned what PHP frameworks are all about, we got to know the most popular ones, we know the differences and what is best guided by the choice. The selection of the corresponding framework is important because it can affect the project, and sometimes even the entire company, but there are no bad solutions. Most of the projects can be implemented in any framework. And the more experience we have in one, we will have more ready solutions made, our confidence in the correct operation will be greater and more importantly, we will create projects faster.
The choice of the framework itself is also very important, but it is more important to take the time to get to know it, look for good patterns and create more and more complex projects in it.
Personally, I recommend Laravel, it is a framework that focuses on programming fun, solves many common problems, and most importantly is the fastest developing framework that has a very engaged community willingly sharing its knowledge and solving the problems of others.
Finally, I would like to emphasize once again — do not waste months looking for the perfect framework for the beginning — choose the solution that you think is the best at first glance. Trust yourself and you will not regret it. Then get ready for a long journey to experience and become an expert in using the solution you choose. Good luck!
This post was originally published at the blog: Marketing i Biznes.