PHP frameworks speed up the development of complex applications greatly. This article features 6 of the most popular frameworks to consider in 2021.
These frameworks provide varying scaffolding levels to get you started, from database operations, object handling, user authentication, and page templating. So you are free to build your application without having to constantly write and re-write the common functions that make your application work.
They also come with some security benefits – using a sanitized database abstraction layer that has been written and reviewed by experts is preferable to rolling your own solution. Similarly, using prebuilt authentication packages which have been reviewed can be better than using your own code.
Popular PHP frameworks have access to thousands of useful prebuilt packages offering new functionality – all of them containing code you don’t have to write yourself. For example, you might want to generate a formatted PDF file for download – you would be able to use a third-party package for this, rather than writing your own complex PDF generator.
Rules for Admission
Frameworks included in this comparison must meet the following conditions:
- For PHP version 7 and up
- Only frameworks with a big online following and variety of packages to provide extra functionality
- Model – Controller – View structure (MCV)
- This splits database and data objects (models), app logic (controllers), and display templates (views) into separate files to keep the application well organized
- It makes complex app codebases easy to manage
- Frameworks I’ve had at least some experience with
The PHP Frameworks
Laravel
Laravel is a well-established and regularly updated PHP framework.
It’s my pick of the lot – I use it for a lot of projects.
I especially use it when I want something to work out of the box so I can start building browser-based apps quickly.
It heavily encourages the use of MVC design to keep your code tidy and organized.
Why it’s Good
- Database migrations make building your database easy – letting you define your database, rollback, and upgrade your databases on the fly while retaining the data in your tables
- Lots (lots!) of third party packages – everything from mapping to sending notifications
- Built-in authentication, database, email, notifications
- HTML templating
- Thorough documentation, popular with tinkerers
Used By
Laravel is very popular with small PHP development houses due to its versatility – many also make their code open source so you can peek at how they do things:
- https://snipeitapp.com/
- https://www.bookstackapp.com/
- https://craterapp.com/
- https://qrporter.com (made by me!)
Laminas (Formerly Zend Framework)
Laminas, formerly known as the Zend Framework, is a long-lived PHP framework with a large online following, especially in enterprise environments.
It doesn’t have as many community packages as other PHP frameworks, but the components that it does offer are rock solid for use in a production environment where stability counts.
Why It’s Good
- Popular with enterprise, so it’s well supported and documented
- Better if you want to start with a sold framework but less scaffolding, such as when developing a REST API
- Pick only the components you need
- Speed and stability
Used By
Enterprises mostly use laminas/Zend, so they tend to be reluctant to disclose exactly how they use it or publish their code publicly. Laminas is used by organizations such as:
- The BBC
- Cisco
- BNP Paribas
CodeIgniter
Codeigniter is the antithesis to Laravel – it doesn’t lock you as strongly into the MVC design pattern and doesn’t come with batteries – it’s very lightweight.
Why It’s Good
- Lightweight and fast – very little is included, so you’re free to build what you want how you want
Why It’s Bad
I include this only for CodeIgniter, as half of the search results for it give reasons why NOT to use it. In summary:
- Insecure
- Insecure
- Insecure
So… Keep that in mind. The lightweight nature of CodeIgniter means that it lacks a lot of the built-in protections of other frameworks and lets you make bad decisions a lot more easily.
Symfony
Symfony is a framework and a set of PHP components. It forms the foundation of many higher-level frameworks, or you can use it directly yourself in your project.
Why It’s Good
- Support for a lot of different database systems
- HTML Templating
- Like Laravel, a huge number of packages available to save you time
- Forums, webcasts, tutorials, and thorough documentation
- They even offer certification
Used By
- The Laravel, Yii, and CakePHP frameworks themselves is actually built on Symfony components
- https://symfony.com/projects/grav
- https://symfony.com/projects/prestashop
- https://symfony.com/projects/magento
Yii
Yii is a PHP framework with great code generation – build forms, database schemas, and logic by answering some questions. If you are building a simple application for managing information, this can get you up and running FAST.
Why It’s Good
- Quick automated code scaffolding
- Solid documentation
- Lots of extensions to add extra functionality
Used By
CakePHP
Like Yii, CakePHP offers code generation tools and built-in validation and authentication. It also offers a collection of components to provide functionality and get your app bootstrapped.
Why It’s Good
- Code Generation
- No need to edit config files
- Lots of components for building functionality without coding it yourself
- Used by a lot of big brands, so it’s doing something right
Used By
On WordPress
WordPress is often used as a platform for PHP projects- but I’ve left it off of the list as it makes a lot of assumptions about how your app will be used.
Extending WordPress is an option if your application is going to work as a blog primarily. Still, I have not found it practical for building applications that have a concept incompatible with the blog website structure. You start with a lot of irrelevant code which needs to be adapted rather than having a clean slate for your idea.
The Best PHP Framework For Beginners, and Overall
The best PHP framework for both beginners and overall for all users is Laravel due to its large community, good documentation, and practicality. Yes, CakePHP and Yii offer code generation for the beginner – but if you’re looking to write and understand code, you’ll need to write code, not generate it.
Great post!! I enjoyed reading the article above, it really explains all the frameworks in detail, the article is very interesting and effective. Keep posting stuff like this.