Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork12
An HTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.
License
amphp/http-server-static-content
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
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.
This package can be installed as aComposer dependency.
composer require amphp/http-server-static-content
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
.
Please readour rules for details on our code of conduct, and the process for submitting pull requests to us.
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.