Lumen Class Route Not found

2019-08-06 11:26发布

I am trying to implement the code stated in Laracast.

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

    return Route::dispatch($proxy);

This gives me error Class Route Not found.My question is how can we use Route:dispatch() in lumen ? Thanks

2条回答
Viruses.
2楼-- · 2019-08-06 11:55

I found the solution for this problem.We can use the following code.

$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);
查看更多
三岁会撩人
3楼-- · 2019-08-06 12:10

// in 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);
查看更多
登录 后发表回答