elemenx/lumen-advanced-route
Composer 安装命令:
composer require elemenx/lumen-advanced-route
包简介
Add Support For Nested Group && Resource.
README 文档
README
inspired by fremail/lumen-nested-route-groups, adding support for lumen resource route.
Changelog
- v.0.1.1 Remove Useless Code.
- v.0.1.0 Add Support For Lumen 5.5 && Resource.
How to install (steps)
1. Install using Composer
composer require "elemenx/lumen-advanced-route:~0.1"
2. Required changes in bootstrap/app.php
Change initialization of Lumen Application class to initialization of Lumen Nested Route Groups Application class in bootstrap/app.php.
Before:
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
After:
$app = new ElemenX\AdvancedRoute\Application(
realpath(__DIR__.'/../')
);
Any() and Match() and resource() methods
Do you like any() and match() methods on Laravel? I love them! That's why I added supporting them on Lumen.
The syntax is the same as for Laravel:
$app->match($methods, $uri, $action);
Where
$methods - an array of methods. Example: ['get', 'post', 'delete']. $uri and $action are the same as on other methods
$app->any($uri, $action);
Here are $uri and $method are the same as on other methods like $app->get(...) etc.
Example of using this lib
This is an example of routes/web.php
$app->group(['middleware' => 'auth'], function () use ($app) {
$app->get('test', function () {
echo "Hello world!";
});
$app->resource('user', 'UserController', ['only' => ['show', 'store', 'destroy']]);
/**
* only admins
*/
$app->group(['middleware' => 'admin'], function () use ($app) {
$app->group(['prefix' => 'admin'], function () use ($app) {
$app->get('/', 'AdminController@index');
});
});
/**
* $app->any and $app->match available from v1.1.0
*/
$app->any('/', function () use ($app) {
echo "Hey! I don't care it's POST, GET, PATCH or another method. I'll answer on any of them :)";
});
$app->match(['PATCH', 'PUT', 'DELETE'], '/old/', function () use ($app) {
echo "This is an old part of our site without supporting REST. Please use only GET and POST here.";
});
});
elemenx/lumen-advanced-route 适用场景与选型建议
elemenx/lumen-advanced-route 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.63k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「route」 「group」 「Match」 「lumen」 「any」 「elemenx」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elemenx/lumen-advanced-route 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elemenx/lumen-advanced-route 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elemenx/lumen-advanced-route 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Interface for Babel Street Text Analytics
AppVerk extension of PHP Matcher, it enables you to match values with patterns
Provides a PHP interface for The AAM Group's RESTful API.
Provide a way to secure accesses to all routes of an symfony application.
A client for Happyr match API
Write down your routing mapping at one place
统计信息
- 总下载量: 9.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-21