Lumen Class 找不到路线

Lumen Class Route Not found

我正在尝试实现 Laracast 中所述的代码。

$proxy = Request::create(
        '/oauth/token',
        'POST'
    );

    return Route::dispatch($proxy);

这给了我错误 Class 找不到路由 。我的问题是我们如何在 lumen 中使用 Route:dispatch() ? 谢谢

我找到了这个 problem.We 的解决方案可以使用下面的代码。

$proxy = Request::create(
        '/oauth/token',
        'post',
        [
            'grant_type'=>$grant_type,
            'client_id'=>$client_id,
            'client_secret'=>$client_secret,
            'username'=>$username,
            'password'=>$password
        ]

    );



    return App::dispatch($proxy);

Lumen 5.4

global $app;    

$proxy = Request::create(
    '/oauth/token',
    'post',
    [
        'grant_type'=>$grant_type,
        'client_id'=>$client_id,
        'client_secret'=>$client_secret,
        'username'=>$username,
        'password'=>$password
    ]

);

return $app->dispatch($proxy);