Skip to main content

Which PHP Framework Should You Use in 2023?


Published: December, 09 2022 | DevDrawer

If you're looking to start a new project or update an existing one, then be sure to check out this explainer and the accompanying video! We'll give you some tips on which PHP framework to use in 2023, based on the needs of your project.

View This On YouTube

Most of the PHP frameworks in this explainer are frameworks I have familiarity with, some recently, some a long time ago. So, I try to be as objective as possible.

What is a PHP framework?

Before we list which are the best PHP frameworks to use, we need to first understand what a PHP framework is. PHP frameworks power anything from simple websites to big, complex web applications that manage millions of registrations and daily visits.

PHP frameworks have been in use for decades now (Phplib, the first PHP framework, dates back to pre-2000), and they’ve taken different forms, but their main purpose has stayed mostly the same. That purpose is: to help PHP developers by providing sets of commonly used functions, as well as libraries for common functionalities, and enforce to the use of best coding practices.

Think of a PHP framework as a skeleton that already provides a running system where you can embed your code without having to go through every detail from scratch.

When to use a PHP framework?

It may sound like a good idea for PHP programmers to use a PHP framework in almost every project, but there are many cases where using one might not be the best idea. It all depends on the project.

Let’s have a quick look at some of the pros and cons of using a PHP Framework.

Cons

  • Slower execution - A PHP framework usually adds complexity and overhead to a project. A PHP framework will always load some number of classes and libraries before running it. Sometimes the best solution might be to just write some custom code at the lowest abstraction level that will be faster and less complex than using a framework.
  • General Solutions for specific problems – A PHP framework provides a skeleton of libraries and functionality that’s ready to use and that should solve the most common problems a developer finds. When you’re choosing a framework, you should be careful to understand if it solves your problem, and then you should check if it fits the rest of your needs.
  • Learning curve - Frameworks pull us towards good, structured code and best practices, however, it may take time and effort to learn and master. If you can’t master the framework, you may end up with a big mess instead of structured code.
  • Limited control – When you use a PHP framework you are introducing an external dependency. With this, you’re accepting that the people in charge of the framework might stop supporting it at any time or move its development in a different direction. You also have to take into consideration the time needed to upgrade the framework to newer versions and having to deal with all the code updates that an upgrade might bring.

Pros

  • Quicker development times - A well-selected PHP framework already contains implementations for the most common problems you must solve built into it. It also usually provides a well-structured application architecture — Model-View-Controller or MVC. By using a framework, you get a fully functional template and only have to focus on building the features specific to your project. Don’t forget about the command-line tools most frameworks offer, they greatly reduce development time.
  • Security - PHP applications do not have good security by default and some developers may not be the best at creating their own security measures. By using a PHP framework, you’re using solutions that are continuously tested, reviewed, and scrutinized by the PHP community. Because most of them are open source, security issues are usually quickly noticed and fixed.
  • Easier collaboration - Using a PHP framework makes it easier for new developers to get started on the project. Even if they’re not already familiar with the framework, they’ll probably have access to complete documentation and tutorials for it to make the transition easier.   It's difficult to get a definitive list of PHP frameworks. Wikipedia lists 40 PHP frameworks, but some of those are better described as content management systems. There are probably many more to choose from.

Here are some of the best PHP frameworks in use today.

Laravel

Let’s get started with Laravel since it is the most popular today.

You can download it and review the documentation here: https://laravel.com/

Laravel was launched in 2011 and is currently on version 9, which was released in 2022. To use version 9, you must be on a PHP version greater than 8.

It's easy to get started with Laravel Homestead, an out-of-the-box virtual development environment. Laravel Homestead is an official pre-packaged Vagrant box that provides you with a wonderful development environment without requiring you to install PHP, a web server, or any other server software on your local machine. No more worrying about messing up your operating system.

If you're a Mac user, you also have the choice of using Laravel Valet as your development environment. Laravel Valet also supports Symfony, CakePHP 3, Slim, and Zend, as well as WordPress

  • Laravel uses a templating engine called Blade. One advantage it has over other templating engines is that you can use PHP within Blade.
  • Packalyst, a collection of Laravel packages, has more than 15,000 packages you can use in your projects to help you get started quicker.
  • Laravel provides a range of security features and methods: for authentication, authorization, email verification, encryption, hashing, and password reset.
  • Laravel's Eloquent ORM and fluent query builder guard against SQL injection attacks as they use PDO parameter binding.
  • Cross-Site Request Forgery protection, which uses a hidden CSRF form token, is also enabled by default.
  • The artisan console command line tool that Laravel has speeds up development by allowing developers to automate repetitive tasks and generate skeleton code fast.
  • Laravel was the fastest of the PHP frameworks I tried and The Laravel ecosystem has several useful tools, such as
  • Mix for compiling CSS and JS assets
  • Socialite for OAuth authentication

Laravel also benefits from a large community of developers, like WordPress. You can find them at Laracasts, a learning portal with courses, a blog, podcasts, and a forum. Laravel.io, is a community portal with over 45,000 users and Laravel even has a subreddit, home to 50,000 Laravel artisans.

Symfony

Next, we have Symfony, the second most used PHP framework.

You can download it and review the documentation here: https://symfony.com/

Symfony was launched in 2005 and is currently on version 6.1.5, which was released in 2022. To use version 6.1.5, you must be on a PHP version greater than 8.

Symfony is both a PHP framework and a collection of PHP components for building websites. Symfony is an excellent choice for websites and apps that need to be scalable. Its modular component system is very flexible and lets you choose the components you need for your project without forcing you to use bloatware.

Out of the most popular PHP frameworks, Symfony supports the most database types like Drizzle, MySQL, Oracle, PostgreSQL, SAP Sybase SQL Anywhere, SQLite, and MSSQL.

The best way to interact with your databases is via the Doctrine ORM. Symfony uses database mappers to map objects to the database. This keeps your object model and the database schema separate meaning that if you change the database column, you don't need to make any changes in your code base.

Debugging Symfony projects is pretty straightforward with its built-in toolbar. Symfony uses the Twig templating engine, which is easy to learn, it's fast and it's secure.

Packagist lists over 4,000 Symfony packages available to you to download and use.

Symfony has commercial backing from SensioLabs. This means there's professional support available, unlike most other PHP frameworks it also has long-term support releases that have three full years of support.

In addition, the Symfony community is huge with over 600,000 developers actively involved.

CodeIgniter


Let’s move on to CodeIgniter.

You can download it and review the documentation here: https://www.codeigniter.com/

CodeIgniter was launched in 2006 and is currently on version 4.1, which was released in 2022. To use version 4.1, you must be on a PHP version greater than 7.4.

CodeIgniter helps you build web apps quickly as it has minimal configuration and is known for its speed. It was the second fastest of the four PHP frameworks I tried in my tests.

The framework has a light footprint of only 1.2 megabytes. So, no bloat. You can add exactly the components you need. CodeIgniter is flexible and encourages development with the MVC architecture, but you can code non-MVC applications too.

The framework includes defenses against CSRF and XSS attacks. Plus, context-sensitive escaping and a content security policy.
CodeIgniter supports multiple methods of caching to help with speeding up your apps. CodeIgniter has an easy learning curve compared to the other frameworks and is quite extensible.

CodeIgniter's community consists of a forum and Slack group.

Zend Framework / Laminas Project


Another favorite of hard-core developers is The Zend Framework.
The Zend Framework was launched in 2006 and is a long-established PHP framework that is now transitioning to the Laminas Project. Migration to Laminas is strongly recommended as Zend is no longer updated.

You can download it and review the documentation here: https://getlaminas.org/

The Laminas Project consists of three parts:

  • Laminas components and MVC
  • Mezeo
  • Laminas API tools

The Zend Framework has had more than 570 million installations and is the most used PHP framework by enterprises and businesses.

Like Symfony, you can use just the components you need.
The Laminas community has a forum and Slack group for collaboration and support.

The Zend Framework probably has the hardest learning curve compared to all of the other frameworks, but it can help you establish yourself as a full-stack developer at many larger corporations if your career is going that route.

CakePHP

Next is an oldie but a goodie.

You can download it and review the documentation here: https://cakephp.org/

CakePHP was launched in 2005 and is currently on version 4.4, which was released in 2022. To use version 4.4, you must be on a PHP version greater than 7.4.

CakePHP serves up fast and clean PHP development and configuration is minimal.

You don't have to mess around with XML or YAML files. Once you set up your database, you can begin coding. CakePHP even has its own built-in ORM, which is quick and simple to use.

Security features include methods for encryption, password hashing, safeguarding form data, and CSRF protection.

CakePHP's components and helpers simplify development and reduce the number of daily tasks you must complete. GitHub has a helpful list of CakePHP resources and plugins that you can use in your project.

You can learn CakePHP through their Cookbook documentation, online training, and CakeFest conferences. You can also find friendly CakePHP bakers through their forums; Stack Overflow, IRC, and Slack.

Pro support is available too from CakeDC, run by CakePHP founder, Larry Masters.

Yii Framework

Next up, Yii.

You can download it and review the documentation here: https://www.yiiframework.com/

Yii was launched in 2006 and is currently on version 2.0.46, which was released in 2022. To use version 2.0.46, you must be on a PHP version greater than 7.4.

Yii means simple and evolutionary in Chinese. It also stands for, Yes It Is.

You can get up and running with Yii within minutes because the documentation is well-written and easy to follow. Yii is fast, lightweight, and easy to get started with.

Yii framework has several security measures, such as bCrypt password hashing, encryption, authentication, and authorization.

Yii has a code generator called Gii that helps you quickly build skeleton code, saving you development time.

The community offers live support via Slack or IRC. There's also a discussion forum and social media channels. The community rewards its active members with badges and entries in a hall of fame to keep the community involved and helpful.

Slim

Need something smaller, try Slim.

You can download it and review the documentation here: https://www.slimframework.com/

Slim was launched in 2010 and is currently on version 4.10.4, which was released in 2022. To use version 4.10.4, you must be on a PHP version greater than 7.4.

Slim is a stripped-down agile micro-PHP framework that focuses on receiving an HTTP request, invoking a callback, and returning an HTTP response.

Slim's code base is lean as it has no third-party dependencies. As a result, it's very fast. Slim is particularly suited to building small apps and APIs.

If you need more from the framework, Slim integrates with both first-party and third-party components. It is easy to learn and understand and you can build a Hello World app in minutes.
Professional support for Slim is available from Tidelift.

FuelPHP

Finally, the youngest framework on my list, FuelPHP.

You can download it and review the documentation here: https://fuelphp.com/

FuelPHP was launched in 2014 and is currently on version 1.9, which was released in 2021. To use version 1.9, you must be on a PHP version greater than 5.3.

FuelPHP is a community-driven PHP framework with over 300 contributors over its lifetime.

FuelPHP uses MVC but also supports HMVC. This adds another layer between the controller and the view. The advantages of the HMVC design pattern are better code organization, greater modularity, more extensibility, and encourages code reuse. You can choose the file and folder structure you want for your project as there are few constraints.

FuelPHP takes security seriously, with features like output encoding, CSRF protection, input, URI, and XSS filtering and escaping user input passed into SQL statements.

FuelPHP has its own command line utility, Oil, which you can use to run tasks, debug code and generate common components.

The FuelPHP ORM is potent yet lightweight.

You can join the FuelPHP community in their forums and on Facebook and Twitter.

What is the best PHP framework for beginners?

The best frameworks for beginners are the ones that are simpler and leaner. If you are just starting out with PHP framework development, keep it small and learn more about the commonly used MVC architecture. Learn this and then move to more robust solutions.

This means Yii, CakePHP, and Slim.

If you have experience with MVC architecture, you may be able to start with Laravel or CodeIgniter since their documentation is phenomenal.

If you are going into the corporate world, maybe Zend / Laminas Project would be the best route for you to learn due to its business implementation capabilities but be warned, there is a learning curve.

Which framework you opt for will depend on the type of app you're building. There are PHP frameworks for all tastes, ranging from the ultra-minimal to everything but the kitchen sink.

Read more articles on DevDrawer


12 11


Share this Article

Like what you see, support the channel.
Buy Me a Coffee