If you're familiar with the concept of a programming framework, you've probably heard of frameworks such as Django, Ruby on Rails, or Laravel. All frameworks have their pros and their cons. Even the creator of PHP teaches you not to use frameworks. For instance, Laravel can be great in some cases, however it is not meant to solve every problem. As Confucius says:
Don't use cannon to kill mosquito.
As such, I wanted to spend a few moments to talk about some lesser known PHP frameworks that pack a punch!
Fat-Free
This little gem has been around for over a decade. Touted as a light full-stack framework, it is very lightweight and getting started is really simple. It has no other dependencies as it uses it's own implementations of libraries such as SMTP, Web Sockets, and Shopping Cart Baskets. It comes with an ORM (called a Mapper), Templating, Caching, and CLI out of the box.
The author has used this is several different side projects with great success in getting work done. The documentation is simple to understand and has a lot of good examples on usage, but like all documentation, it can be improved.
It has been in version 3 for nearly 9 years and some of the coding style is showing it's age, but it is still compatible all the way up to PHP 8.2.
Sample "Hello World" Example:
<?php
$f3 = require('path/to/base.php');
$f3->route('GET /', function() {
echo 'Hello World';
});
$f3->run();
Mako
Mako hails from the land of Norway by it's creator freost. While many frameworks are billed as "light" and "fast", this one actually is light and fast and it includes the kitchen sink!
It has everything you need from basic routing, to encryption/signing, ORM, I18n, Logging, Sessions, Templating and more!
Version 9 has come out as of 12/2022 which drops support for PHP 7.4. Version 8 is still available to support version 7.4.
Sample "Hello World" Example:
app/routing/routes.php
<?php
/** @var \mako\http\routing\Routes $routes */
$routes->get('/', function() {
return "Hello World";
});
Flight
This is a micro-framework from Mike Cao, meaning it doesn't have all the other bells and whistles another larger framework might have. What is lacks in features though it makes up for in speed!
It has a great routing platform, a basic templating system, and an easy to extend interface should you choose to override existing functionality.
It hasn't been updated in about a year from the time of writing, but it does have support up to PHP 8.1!
Sample "Hello World" Example:
<?php
require 'flight/Flight.php';
Flight::route('/', function(){
echo 'Hello World';
});
Flight::start();
Nette
Nette has actually been around for quiet some time originating from Czech Republic. This is a full stack "framework" or rather system of components you can use to build your web application. They follow the typical MVC setup but choose the name Presenter
over Controller
. As an added bonus, there are "plugins" you can add to your Nette setup at
You may have already used some of Nette's tools in other projects you've worked on and not known it! There is the very extendable Tracy for debugging similar to Whoosh, and Latte for intuitive HTML templating.
Version 3.1.8 was released 11/2022 which supports PHP 7.2 - 8.2. Version 4 (in the works) will support PHP 8+.
Sample "Hello World" Example:
app/Presenters/RouterFactory.php
<?php
declare(strict_types=1);
namespace App\Router;
use Nette;
use Nette\Application\Routers\RouteList;
final class RouterFactory
{
use Nette\StaticClass;
public static function createRouter(): RouteList
{
$router = new RouteList;
$router->addRoute('/', 'Homepage:view');
return $router;
}
}
app/Presenters/HomepagePresenter.php
<?php
declare(strict_types=1);
namespace App\Presenters;
use Nette;
final class HomepagePresenter extends Nette\Application\UI\Presenter
{
public function renderView() {
$this->sendResponse(new \Nette\Application\Responses\TextResponse('Hello World'));
}
}
FOMO
FOMO is created by Iranian developer amirfaramarzi. This framework sits on top of the asynchronous event driven framework swoole that creates insane levels of performance out of apps (we're talking Go/Rust level of performance)! Check out the performance on the Web Frameworks Benchmark.
This is a micro framework that has your basic routing, controllers, and middleware similar to SlimPHP. You do have to install the swoole
extension in order for this to work properly so there is that added complexity (though hopefully it's easy with your setup).
Sample "Hello World" Example:
router/router.php
<?php
use Fomo\Facades\Route;
Route::get('/', function () {
return response()->plainText('Hello World');
});
Start the swoole server:
php engineer server:start
Conclusion
As you can see, there are lots of options when it comes to framework, each one have it's own set of trade-offs. Are you creating a simple API? Well you might not need a full blown Laravel/Cake/Yii app for that. Are you building a robust enterprise software in a bustling work environment with thousands of active clients? That might make more sense for Laravel or Symfony.
Top comments (0)