empress-php/empress

Empress is a flexible microframework for creating async web applications in PHP 8.

0.5.0 2022-06-30 18:22 UTC

This package is auto-updated.

Last update: 2024-04-14 21:48:31 UTC


README

Build Latest Stable Version Coverage Status License: MIT

Work in progress ⚡

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.

Documentation

Read the Wiki for more information and make sure to check out the Getting Started tutorial.

Taste it

<?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