gpt4 book ai didi

php - Lumen 中的路由组错误调用未定义的方法 Laravel\Lumen\Application::group()

转载 作者:可可西里 更新时间:2023-11-01 13:46:45 27 4
gpt4 key购买 nike

我在 laravel/lumen 中声明了一个路由组,如下所示:

$app->group(['middleware' => 'auth'], function () use ($app) {
$app->get('/details', 'UserController@details');
});

路由文件web.php的全部内容如下:

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$app = app();

$router->get('/', function () use ($router) {
return $router->app->version();
});


$app->group(['middleware' => 'auth'], function () use ($app) {
$app->get('/details', 'UserController@details');
});

调用http://THE_URL/

我得到一个错误 Call to undefined method Laravel\Lumen\Application::group()

ERROR

如何使用中间件添加路由组?

最佳答案

实际上正如@Aine 在 Lumen 5.5+ 中所说,您应该更改:

LumenPassport::routes($this->app);

LumenPassport::routes($this->app->router);

应用程序不再有 group() 方法。

谢谢

关于php - Lumen 中的路由组错误调用未定义的方法 Laravel\Lumen\Application::group(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46349867/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com