简体   繁体   中英

lumen route error handleDispatcherResponse(array('0'))

Below is my route in lumen.

$app->get('contact-us/{msg?}', function (){
    echo Input::all();
});

It throws the following error.

at Application->handleDispatcherResponse(array('0')) in Application.php line 1184
at Application->Laravel\Lumen\{closure}() in Application.php line 1414
at Application->sendThroughPipeline(array(), object(Closure)) in Application.php line 1185
at Application->dispatch(object(Request)) in Application.php line 1125
at Application->run(object(Request)) in index.php line 31

I want to pass the optional parameter msg to controller. How to pass it?

In public/index.php do the following edit:

//$app->run();
$app->run($app->make('request'));

It seems that the rewrite rules of your Apache or Nginx sever aren't correctly set, so Lumen cannot parse the URL in the right way. If you're using Nginx , please use this config:

index  index.html index.htm index.php;
location @rewrite {
    rewrite ^/(.*)$ /index.php;
}   
location / {
    try_files $uri $uri/ @rewrite;
}

And routes should start with / :

$app->get('/contact-us/{msg?}', function () {
    echo Input::all();
});

If these solutions didn't work, try debugging with RoutesRequests.php , adding some debug outputs will be helpful.

To send the data to the controller do the following

$app->get('contact-us/{msg?}', 'YourController@mehtod');

And in your controller you will receive data as well

public function method($message)
{

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM