定制 jetwaves/laravel-implicit-router 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jetwaves/laravel-implicit-router

Composer 安装命令:

composer require jetwaves/laravel-implicit-router

包简介

A simple Implicit Router/Controller Router for Laravel whose version >= 5.2 ( 5.5 tested )

README 文档

README

A simple Implicit Implicit Router/ Controller Router for Laravel whose version >= 5.2 ( 5.5 tested )

CREDIT TO dingo/api and laravel framework

HOW TO USE:

(exemple tested working well in Laravel 5.5 / should be the same in Laravel 5.2 5.3 5.4 )

Situation:

From Laravel 5.2, the feature implicit controller routing has been removed.

But some projects have thousands of routing rules to declare.

Solution:

  1. run command:

     composer require jetwaves/laravel-implicit-router
  2. in your api.php or web.php in routes, add this following lines (1).

     <?php
     $api = app('Jetwaves\LaravelImplicitRouter\Router');
     $api->controller('URI_PREFIX', 'App\Http\Controllers\TestController');
  3. in your App/Http/Controllers/TestController.php, add a function like

     <?php
     public function getShowMeTheMoney(Request $req){
         return '10000 gold';
     }
  4. then we can access this controller by http://hostname/URI_PREFIX/show-me-the-money and get the following response in your browser. Just like the implicit controller routing of Laravel 5.1 at old time.

     10000 gold          
    
  5. All Http method keywords are allowed to be the prefix of Camel Type function name to serve correspondent http methods.

  6. When function does not exists, you'll get a 404 of laravel itself.

  7. Declare explicit routes in the original way. (nothing changed)

Middleware support:

code snippet (1) could be used in a closure of middlewares.

Route::middleware(['test'])->group(function () {
    $api = app('Jetwaves\LaravelImplicitRouter\Router');
    $api->controller('URI_PREFIX', 'App\Http\Controllers\TestController');
});

when the 'test' middleware do

echo 'starcraft tricks :'

and you access http://hostname/URI_PREFIX/show-me-the-money, you'il get

starcraft tricks : 10000 gold

in browser.

Probably a ungraceful solution but save your time and life. :-)

TODO:

  1. Support some frequently used 'native' middleware declarations, in the line of route declaration.
  2. Beautify the php source code and this readme file.
  3. Make it functional for lumen.
  4. Show me your stars 8-D .

jetwaves/laravel-implicit-router 适用场景与选型建议

jetwaves/laravel-implicit-router 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.32k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jetwaves/laravel-implicit-router 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jetwaves/laravel-implicit-router 我们能提供哪些服务?
定制开发 / 二次开发

基于 jetwaves/laravel-implicit-router 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 6
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-13