laasti/route
Composer 安装命令:
composer require laasti/route
包简介
Two-step controller routing for League/route. Instantiate your controller, do some stuff, then call your controller method.
README 文档
README
An advanced implementation of PHP League Route package. A two-step route middleware for Laasti/Stack.
Instead of mapping directly to your controller, a middle step is added: a route object is used to configure the current route. This middle step can be used to check user's rights to access a route through an Authorization middleware.
Uses the excellent package from The PHP League: League/Route.
Installation
composer require laasti/route
Usage
Currently does not support closures nor functions as routes, only objects.
With Laasti\Stack:
$container = new League\Container; $routes = new League\Route\RouteCollection($container); $container->add('Laasti\Route\DefineControllerMiddleware')->withArgument($routes); $routes->setStrategy(new Laasti\Route\ControllerDefinitionStrategy); $request = Symfony\Component\HttpFoundation\Request::create('/test'); $routes->get('/test', 'MyController::display'); $resolver = new Laasti\Stack\ContainerResolver($container); $stack = new Laasti\Stack\Stack($resolver); $stack->push('Laasti\Route\DefineControllerMiddleware'); $stack->push('Laasti\Route\CallControllerMiddleware'); $stack->execute($request);
Without Laasti\Stack:
$container = new League\Container; $routes = new League\Route\RouteCollection($container); $routes->setStrategy(new Laasti\Route\ControllerDefinitionStrategy); $request = Symfony\Component\HttpFoundation\Request::create('/test/George'); $routes->get('/test/{name}', 'MyController::display'); $definition = $routes->getDispatcher()->dispatch($request->getMethod(), $request->getPathInfo()); //Pass the request or any arguments to the controller //Calls MyController->display($request); $request->attributes->add($definition->getArguments()); echo $definition->callController($request); //Or, uses route attributes as arguments //Calls MyController->display($name); echo $definition->callController();
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request :D
History
See CHANGELOG.md for more information.
Credits
Author: Sonia Marquette (@nebulousGirl)
License
Released under the MIT License. See LICENSE.txt file.
laasti/route 适用场景与选型建议
laasti/route 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 199 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laasti/route 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laasti/route 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 199
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-15