amphp/http-server-static-content
Composer 安装命令:
composer require amphp/http-server-static-content
包简介
Static content request handler for Amp's HTTP server.
README 文档
README
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. This package provides an HTTP server plugin to serve static files like HTML, CSS, JavaScript, and images effortlessly.
Installation
This package can be installed as a Composer dependency.
composer require amphp/http-server-static-content
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 to demonstrate how they work well together:
<?php use Amp\Http\Server\DefaultErrorHandler; use Amp\Http\Server\RequestHandler\ClosureRequestHandler; use Amp\Http\Server\Response; use Amp\Http\Server\SocketHttpServer; use Amp\Http\Server\StaticContent\DocumentRoot; use Amp\Http\Status; $router = new Amp\Http\Server\Router; // $server is an instance of HttpServer and $errorHandler an instance of ErrorHandler $router->setFallback(new DocumentRoot($server, $errorHandler, __DIR__ . '/public')); $router->addRoute('GET', '/', new ClosureRequestHandler(function () { return new Response(Status::OK, ['content-type' => 'text/plain'], 'Hello, world!'); })); $server->start($router, new DefaultErrorHandler());
A full example is found in examples/server.php.
Contributing
Please read our 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 see LICENSE for more information.
amphp/http-server-static-content 适用场景与选型建议
amphp/http-server-static-content 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 72.26k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2018 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「file」 「http」 「static」 「server」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 amphp/http-server-static-content 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amphp/http-server-static-content 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 amphp/http-server-static-content 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
TwigStan is a static analyzer for Twig templates powered by PHPStan
Laravel Media Popup to upload/view the files
PMVC Plugin for File information
统计信息
- 总下载量: 72.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 23
- 依赖项目数: 19
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-13