Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An HTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.

License

NotificationsYou must be signed in to change notification settings

amphp/http-server-static-content

Repository files navigation

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. This package provides anHTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.

Installation

This package can be installed as aComposer dependency.

composer require amphp/http-server-static-content

Usage

This package provides twoRequestHandler implementations:

  • DocumentRoot: Serves all files within a directory.
  • StaticResource: Serves a single specific file.

The example below combines static file serving andrequest routing to demonstrate how they work well together:

<?phpuseAmp\Http\Server\DefaultErrorHandler;useAmp\Http\Server\RequestHandler\ClosureRequestHandler;useAmp\Http\Server\Response;useAmp\Http\Server\SocketHttpServer;useAmp\Http\Server\StaticContent\DocumentRoot;useAmp\Http\Status;$router =newAmp\Http\Server\Router;// $server is an instance of HttpServer and $errorHandler an instance of ErrorHandler$router->setFallback(newDocumentRoot($server,$errorHandler,__DIR__ .'/public'));$router->addRoute('GET','/',newClosureRequestHandler(function () {returnnewResponse(Status::OK, ['content-type' =>'text/plain'],'Hello, world!');}));$server->start($router,newDefaultErrorHandler());

A full example is found inexamples/server.php.

Contributing

Please readour rules for details on our code of conduct, and the process for submitting pull requests to us.

Security

If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.

License

The MIT License (MIT). Please seeLICENSE for more information.

About

An HTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp