alanalbert / imi-route
There is no license information available for the latest version (1.0.0) of this package.
为IMI框架添加rou路由文件
1.0.0
2020-05-27 09:32 UTC
Requires
- yurunsoft/imi: ~1.0
This package is auto-updated.
Last update: 2025-01-20 21:09:13 UTC
README
中文 | English
使用laravel的方式管理imi的路由。
使用
1、使用composer安装依赖:
composer require alanalbert/imi-route
2、将下列代码添加到项目根目录的Main.php
文件中:
<?php namespace ImiApp; use Imi\Main\AppBaseMain; class Main extends AppBaseMain { public function __init() { \Alan\ImiRoute\Route::init(); // Add this line } }
3、在项目根目录下,创建route/route.php
目录及文件,在route.php
文件中,你就可以管理你的路由了:
/** * @var $router Route */ use Alan\ImiRoute\Route; use ImiApp\ApiServer\Controller\IndexController; use ImiApp\ApiServer\Middleware\Test2Middleware; use ImiApp\ApiServer\Middleware\TestMiddleware; $router->group(['middleware' => TestMiddleware::class], function (Route $router) { $router->group( [ 'middleware' => Test2Middleware::class, 'ignoreCase' => true, 'prefix' => 'prefix' ], function (Route $router) { $router->get('hi', 'ImiApp\ApiServer\Controller\IndexController@index'); }); $router->any('/hi/api/abc', [IndexController::class, 'index']); $router->any('/hi/api/{time}', [IndexController::class, 'api']); }); $router->group(['prefix' => 'prefix'], function (Route $router) { $router->get('/TEST/{time}', [IndexController::class, 'api']); });