PHPackages                             amphp/http-server-static-content - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. amphp/http-server-static-content

ActiveLibrary[HTTP &amp; Networking](/categories/http)

amphp/http-server-static-content
================================

Static content request handler for Amp's HTTP server.

v2.0.0(2y ago)2167.2k—2.6%12[1 issues](https://github.com/amphp/http-server-static-content/issues)12MITPHPPHP &gt;=8.1CI failing

Since Sep 14Pushed 10mo ago5 watchersCompare

[ Source](https://github.com/amphp/http-server-static-content)[ Packagist](https://packagist.org/packages/amphp/http-server-static-content)[ Docs](https://github.com/amphp/http-server-static-content)[ GitHub Sponsors](https://github.com/amphp)[ RSS](/packages/amphp-http-server-static-content/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (14)Used By (12)

http-server-static-content
==========================

[](#http-server-static-content)

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. This package provides an [HTTP server](https://amphp.org/http-server) plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.

Installation
------------

[](#installation)

This package can be installed as a [Composer](https://getcomposer.org/) dependency.

```
composer require amphp/http-server-static-content
```

Usage
-----

[](#usage)

This package provides two `RequestHandler` implementations:

- **`DocumentRoot`**: Serves all files within a directory.
- **`StaticResource`**: Serves a single specific file.

The example below combines static file serving and [request routing](https://amphp.org/http-server-router) to demonstrate how they work well together:

```
