york8/poa
Composer 安装命令:
composer require york8/poa
包简介
POA Web框架灵感来自于Node.js的KOA框架,基于React-PHP,使用生成器来实现中间件,轻松的组合管理多个中间件之间的协作
README 文档
README
POA(Php cOroutine based Application framework)Web框架,灵感来自于 Node.js 的 KOA 框架,基于 React-PHP, 使用 PHP 的生成器来实现中间件,轻松的组合管理多个中间件之间的协作。
作者
安装
composer require york8/poa
使用
// 1. create the Application $app = new Application(); // 2. define the route rules $router = new RouterMiddleware(function (Context $context) { $context->statusCode(404)->send('Not Found'); }); $router->get( '/foo/bar$', function (Context $context) { $context->send('Hello, ' . $context->getRequest()->getUri()); } )->get( '/foo/exception', function () { throw new Exception('I throw an exception just for fun, haha!'); } ); // 3. use middlewares what you need $app->use(new ProfileMiddleware()) // simple error handle middleware ->use(function (Context $context) { try { yield; } catch (Exception $e) { fwrite(STDERR, 'EXP: ' . $e->getMessage() . "\n"); $context->statusCode(500)->send('Exp: ' . $e->getMessage()); } }) ->use(function (Context $context) { $uri = $context->getRequest()->getUri(); if ($uri->getPath() === '/bar') { $context->send('you fire.'); return false; } return null; }) ->use($router) // global error handle middleware ->useErrorMiddleware(function (Throwable $throwable, Context $context) { // handle global exception $msg = $throwable->getMessage(); fwrite(STDERR, 'Global Exp: ' . $msg . "\n"); if ($context) { $context->statusCode(500)->send('Oh, No! ' . $msg); } }); // 4. listen and start the server $app->listen(8088);
License
The MIT License (MIT). Please see License File for more information.
york8/poa 适用场景与选型建议
york8/poa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「generator」 「middleware」 「react-php」 「koa」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 york8/poa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 york8/poa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 york8/poa 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Shoot aims to make providing data to your templates more manageable
Slim Framework 3 CSRF protection middleware utilities
Cloudflare Middleware For Guzzle
PSR-15 middleware to handle CSRF-token verification
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-19