Empress is a flexible PHP 8.1 microframework for creating async web applications. It's based on amphp/http-server. The name is a portmanteau of Express and Amp as Empress's simplicity was first inspired by Express.js. Later, many useful ideas were incorporated from Spark and Javalin. Ultimately it's also the name of one of the cards from major arcana, part of the tarot deck.
Read the Wiki for more information and make sure to check out the Getting Started tutorial.
<?php
// app.php
use Empress\Application;
use Empress\Context;
use Empress\Routing\RouteCollector\AnnotatedRouteCollectorTrait;
use Empress\Routing\RouteCollector\Attribute\Group;
use Empress\Routing\RouteCollector\Attribute\Route;
#[Group('/hello')]
class IndexController
{
use AnnotatedRouteCollectorTrait;
#[Route('GET', '/')]
public function index(Context $ctx)
{
$ctx->response('<h1>Hello!</h1>');
}
}
$app = Application::create(9010);
$app->routes(new IndexController());
return $app;
// Run it:
// vendor/bin/empress app.php