PHP code example of empress-php / empress
1. Go to this page and download the library: Download empress-php/empress library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
empress-php / empress example snippets
// 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