Http Server ⋅ Introduction
Amp’s HTTP server is a non-blocking HTTP/1.1 and HTTP/2 application server written in PHP. This means that there’s no Apache or Nginx required to serve PHP applications with it. Multiple requests can be served concurrently and the application bootstrapping only needs to happen once, not once for every request.
The server can be installed as a Composer dependency.
composer require amphp/http-server
You can then access the example server at
http://localhost:1337/ in your browser.
Server uses a
NullLogger by default.
If you pass a
Psr\Log\LoggerInterface instance to its constructor, you’ll get helpful log messages.
Optionally you can use
Options::withRequestLogContext() to enable passing the
Request object to the logger in the
$context array. This is disabled by default.
Internally generated log messages of the
DEBUGlevel are only generated if
zend.assertionsis set to
1. If it isn’t set to
1in your config, load the server with
php -d zend.assertions=1 examples/hello-world.php.