{"id":19665943,"url":"https://github.com/amphp/http-server-static-content","last_synced_at":"2025-04-28T22:31:31.736Z","repository":{"id":30414396,"uuid":"124811232","full_name":"amphp/http-server-static-content","owner":"amphp","description":"An HTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.","archived":false,"fork":false,"pushed_at":"2024-01-23T08:29:01.000Z","size":119,"stargazers_count":21,"open_issues_count":1,"forks_count":12,"subscribers_count":6,"default_branch":"2.x","last_synced_at":"2025-04-19T13:13:52.599Z","etag":null,"topics":["amphp","document-root","http","http-server","php","revolt","static-content","static-files"],"latest_commit_sha":null,"homepage":"https://amphp.org/http-server-static-content","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-12T00:02:59.000Z","updated_at":"2025-03-02T14:29:09.000Z","dependencies_parsed_at":"2023-11-27T10:28:34.295Z","dependency_job_id":"e47bbd3a-feb0-4c1a-bcb5-1151d8d0f6ae","html_url":"https://github.com/amphp/http-server-static-content","commit_stats":{"total_commits":67,"total_committers":4,"mean_commits":16.75,"dds":0.3731343283582089,"last_synced_commit":"074b9e0ba82723ddbf81c1b4e8eff46f8e303b00"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-server-static-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-server-static-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-server-static-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-server-static-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amphp","download_url":"https://codeload.github.com/amphp/http-server-static-content/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251397611,"owners_count":21583041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amphp","document-root","http","http-server","php","revolt","static-content","static-files"],"created_at":"2024-11-11T16:25:33.813Z","updated_at":"2025-04-28T22:31:30.496Z","avatar_url":"https://github.com/amphp.png","language":"PHP","readme":"# http-server-static-content\n\nAMPHP 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. \n\n## Installation\n\nThis package can be installed as a [Composer](https://getcomposer.org/) dependency.\n\n```bash\ncomposer require amphp/http-server-static-content\n```\n\n## Usage\n\nThis package provides two `RequestHandler` implementations:\n - **`DocumentRoot`**: Serves all files within a directory.\n - **`StaticResource`**: Serves a single specific file.\n\nThe example below combines static file serving and [request routing](https://amphp.org/http-server-router) to demonstrate how they work well together:\n\n```php\n\u003c?php\n\nuse Amp\\Http\\Server\\DefaultErrorHandler;\nuse Amp\\Http\\Server\\RequestHandler\\ClosureRequestHandler;\nuse Amp\\Http\\Server\\Response;\nuse Amp\\Http\\Server\\SocketHttpServer;\nuse Amp\\Http\\Server\\StaticContent\\DocumentRoot;\nuse Amp\\Http\\Status;\n\n$router = new Amp\\Http\\Server\\Router;\n// $server is an instance of HttpServer and $errorHandler an instance of ErrorHandler\n$router-\u003esetFallback(new DocumentRoot($server, $errorHandler, __DIR__ . '/public'));\n$router-\u003eaddRoute('GET', '/', new ClosureRequestHandler(function () {\n    return new Response(Status::OK, ['content-type' =\u003e 'text/plain'], 'Hello, world!');\n}));\n\n\n$server-\u003estart($router, new DefaultErrorHandler());\n```\n\nA full example is found in [`examples/server.php`](https://github.com/amphp/http-server-static-content/blob/2.x/examples/server.php). \n\n## Contributing\n\nPlease read [our rules](https://amphp.org/contributing) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Security\n\nIf you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](./LICENSE) for more information.\n","funding_links":[],"categories":["HTTP"],"sub_categories":["Server"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fhttp-server-static-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famphp%2Fhttp-server-static-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fhttp-server-static-content/lists"}