mariuslundgard / php-server
A minimal routable HTTP middleware framework for PHP.
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mariuslundgard/php-server
Requires
- php: >=5.4.13
- mariuslundgard/php-core: dev-develop
- mariuslundgard/php-debug: dev-develop
- mariuslundgard/php-event: dev-develop
- mariuslundgard/php-socket: dev-develop
- mariuslundgard/php-util: dev-develop
Requires (Dev)
- apigen/apigen: ~2.8
- mayflower/php-codebrowser: ~1.1
- nette/nette: ~2.1.3
- pdepend/pdepend: ~2.0
- phploc/phploc: *
- phpmd/phpmd: dev-master
- phpunit/php-invoker: dev-master
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: dev-master
- sebastian/finder-facade: dev-master
- sebastian/phpcpd: ~1.4
- squizlabs/php_codesniffer: ~1.4
- theseer/fdomdocument: dev-master
This package is not auto-updated.
Last update: 2025-10-07 08:09:50 UTC
README
Features
- Routable middleware (application layers)
- Routable controller actions
Examples
This is the canonical Hello World example:
<?php require 'vendor/autoload.php'; $app = (new Server\Module()) ->map([ 'fn' => function ($req, $res) { $res->write('<h1>Hello, world</h1>'); } ]) ->call() // calls the application ->send(); // outputs the headers and response body
This example shows how to use middleware and map controllers:
<?php require 'vendor/autoload.php'; class HeaderFilter extends Server\Layer { public function call(Server\Request $req = null, Server\Error $err = null) { $res = parent::call($req, $err); $res->body = '<h1>'.$res->body.'</h1>'; return $res; } } class FrontController extends Server\Controller { public function index() { return 'Hello, world!'; } } $app = new Server\Module(); $app->employ([ 'class' => 'HeaderFilter', ]); $app->map([ 'controller' => 'FrontController', ]); $app->call()->send(); // outputs: <h1>Hello, world!</h1>