Documentation Packages Support

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

Several advanced components are available in separate packages, such as a routing, static content and WebSocket component.


Several examples can be found in the ./examples directory of the repository. These can be executed as normal PHP scripts on the command line.

php examples/hello-world.php

You can then access the example server at http://localhost:1337/ in your browser.


The 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 DEBUG level are only generated if zend.assertions is set to 1. If it isn’t set to 1 in your config, load the server with php -d zend.assertions=1 examples/hello-world.php.