【问题标题】:Lumen Class Route Not found流明类路由未找到
【发布时间】:2017-08-19 16:37:31
【问题描述】:

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

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

    return Route::dispatch($proxy);

这给了我错误 Class Route Not found。我的问题是我们如何在 lumen 中使用 Route:dispatch() ? 谢谢

【问题讨论】:

  • Lumen 使用完全不同的路由器,这个:github.com/nikic/FastRoute
  • 所以通过使用 fastRoute 我可以解决上述问题对吗?

标签: laravel lumen laravel-passport


【解决方案1】:

流明 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);

【讨论】:

  • 如何在上面添加新的标题?任何想法
【解决方案2】:

我找到了解决这个问题的方法。我们可以使用以下代码。

$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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 2014-10-02
    • 2016-11-22
    • 2017-09-29
    • 2018-12-04
    • 2019-03-21
    • 2016-02-27
    相关资源
    最近更新 更多