您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-路由-闭包路由
发布时间:2022-01-18 22:22:14编辑:雪饮阅读()
闭包路由不经过控制器
由于闭包函数不属于任何控制器,所以$request->app $request->controller $request->action 全部为空字符串。
闭包路由实现:
在config/route.php新增配置后如:
<?php
/**
* This file is part of webman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Webman\Route;
Route::any('/test', function ($request) {
$arr["app"]=$request->app;
$arr["controller"]=$request->controller;
$arr["action"]=$request->action;
return response(var_export($arr,true));
});
路由被请求时:
[root@localhost wwwroot]# elinks http://192.168.31.53:8787/test --dump
array ( 'app' => '', 'controller' => '', 'action' => '', )
关键字词:webman,路由,闭包路由