phpgram/phpgram
Composer 安装命令:
composer require phpgram/phpgram
包简介
A very fast and lightweight Php Framework for small to enterprise applications
关键字:
README 文档
README
phpgram
A very fast and lightweight Php Framework for small to enterprise applications.
RouteHandler for Functions and Classes
Request and Response via Psr-7
Middleware via Psr-15
Psr 11 Container Support for Automatic Dependency Injection (Autowiring) for Route Callable: Class (in constructor) or Function (with
`__get()`)Response Creation (via Psr-17 Response Factory) and Strategies
Supports Async Requests
Install
Via Composer
composer require phpgram/phpgram
Documentation
<?php
use Gram\App\App;
use Gram\Strategy\StdAppStrategy;
App::app()->debugMode(true); //true (default) -> show Exceptions, false -> show empty page
App::app()->setStrategy(new StdAppStrategy()); //define how the Output will be created (StdAppStrategy is default)
App::app()->set404("Er404@404"); //404 Handler
App::app()->set405("Er405@405"); //405 Handler
//Middleware will be executed before the Router
App::app()
->addMiddleware(new Session())
->addMiddleware(new Authenticate());
//Routes and Groups
App::app()->get("/","Index@index"); //static Route
//dynamic Route with Middleware (this Middleware will only executed if the Routes is matched
App::app()->get("/video/{id:n}","Video@watch")->addMiddleware(new Caching);
//Nested Group with Middleware
// /admin will be the prefix for all Routes in this Group
App::app()->group("/admin",function (){
App::app()->get("","AdminIndexHandler");
App::app()->get("/role","RoleHandler");
//Nested Groups
//2. Group /settings
App::app()->group("/settings",function (){
//3. Group /dep
App::app()->group("/dep",function (){
//Routes
App::app()->get("","DepIndexHandler");
App::app()->get("/{id}/edit","EditHandler");
});
})->addMiddleware(new Auth());
})->addMiddleware(new Login());
//Group with different Output Strategy (json)
use Gram\Strategy\JsonStrategy;
App::app()->group("/",function (){
App::app()->getpost("video/vote/{id:n}","Video@vote");
App::app()->getpost("video/getComment/{id:n}","Video@getComments");
})->addStrategy(new JsonStrategy());
//Psr 7 Request
// in this case with Nyholm Psr 7
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7Server\ServerRequestCreator;
$psr17Factory = new Psr17Factory();
$creator = new ServerRequestCreator($psr17Factory,$psr17Factory,$psr17Factory,$psr17Factory);
$request = $creator->fromGlobals();
//App needs a Psr 17 Response Factory
App::app()->setFactory($psr17Factory);
//get the response with the content
$response = App::app()->start($request);
//simple emit:
echo $response->getBody(); // don't do this in production use an psr 7 emitter!
License
phpgram is open source and under MIT License
Credits
Router
Algorithm and Core Implementation: Copyright by Nikita Popov. (FastRoute)
Parser: Copyright by Nikita Popov and Phil Bennett (thephpleague)
phpgram/phpgram 适用场景与选型建议
phpgram/phpgram 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.89k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 08 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「api」 「micro」 「di」 「frameworks」 「middleware」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpgram/phpgram 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpgram/phpgram 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpgram/phpgram 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Anax htmlform module.
Micro Active Record library in PHP, support chain calls, events, and relations.
A PSR-7 compatible library for making CRUD API endpoints
Onix Micro Framework
PHP classes for database handling upon PDO
统计信息
- 总下载量: 4.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 27
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-25
