Hi,
I am not sure if everyone encounters this problem, but right after I created Lumen project 5.3, and set the key in .env file. I got this error without doing anything yet.
NotFoundHttpException in RoutesRequests.php line 461:
in RoutesRequests.php line 461
at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 399
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 650
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 400
at Application->dispatch(null) in RoutesRequests.php line 341
at Application->run() in index.php line 28
I googled the problem, there is a workaround by editing the file index.php and change it to this:
$app->run($app->make('request'));
After that work around, I was able to get the example up and running:
Lumen (5.3.1) (Laravel Components 5.3.*)
But for global middleware or route middleware, $request does not contain any input parameters as specified in routes.php, retrieve input always return NULL and it fails miserably.
Can somebody let me know what is the correct way to configure this Lumen? The full Laravel framework works flawlessly but its cousin does work as expected and it failed right after install.
Thank you.
Same problem here!
Sorry, the page you are looking for could not be found.
1/1
NotFoundHttpException in RoutesRequests.php line 461:
in RoutesRequests.php line 461
at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 399
at Application->Laravel\Lumen\Concerns{closure}() in RoutesRequests.php line 650
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 400
at Application->dispatch(null) in RoutesRequests.php line 341
at Application->run() in index.php line 28
Same here - my $app->get() route is found, but my post/put/patch/delete routes are not
It is also failing with @sereysethy's workaround
// index.php
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: origin, content-type, accept");
$app = require __DIR__.'/../bootstrap/app.php';
$app->run($app->make('request'));
// routes.php
<?php
$app->delete('api/glossary/term', 'GlossaryController@deleteTerm');
$app->get('api/glossary', 'GlossaryController@index');
$app->put('api/glossary', 'GlossaryController@put');
GET request working as expected:

...Failing OPTIONS(POST) request:

same here, I am working on windows, apache/php7.0
Which address were you using?
I had the same problem today.
I was accessing it using the url http://localhost/lumen.api/public/ and I think that was the cause of the error.
To get around it, this is what I did:
First I configured a new VirtualHost entry on Xampp, located in "C:\xampp\apache\conf\extra\httpd-vhosts.conf" in my case:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/lumen.api/public"
ServerName lumen.api
ServerAlias www.lumen.api
ErrorLog "logs/lumen.api-error.log"
CustomLog "logs/lumen.api-access.log" common
<Directory "C:/xampp/htdocs/lumen.api/public">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
and restarted Apache on Xampp.
Then I edited my hosts file (c:\windows\system32\drivers\etc\hosts) to map a new address to my localhost.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lumen.api
I tried again using the new URL http://lumen.api and the error was gone.
As @zemigpt, most of these issues sound like they were trying to route to a subdirectory (i.e. example.com/path instead of example.com).
Sub directory routing didn't work correctly because the getPathInfo method on RoutesRequests didn't remove the sub directory before attempting to route the request. That was removed in #575 so you shouldn't have that issue anymore.
@yuloh Before #575, I always add prefix to handle sub directory routing in Lumen. Now I can remove the prefix. Thanks.
But, will it lead to lower performance?
But, will it lead to lower performance?
Technically yes, because a request object is created on every request. If you are typehinting Request anywhere in your app it won't make a difference though, since it is being created anyway.
I personally have 0 endpoints that don't use Request, since my GET routes still use Request to get parameters for pagination, filters, sorting etc.
You would also have to not be using any middleware at all to see a difference, since the request is created if you have middleware.
I have solved the problem. Look its your routes/web.php
$router->get('user','userController@index');
$router->get('user/{id}','userController@getuser');
$router->post('user','userController@createuser');
$router->post('user/{id}','userController@updateuser');
$router->delete('user/{id}','userController@deleteuser');
So you have to use this cmd when you start server
php -S localhost:8000 -t public
and after that you can use postman or browser for check. I have given the url for get all the users.
localhost:8000/user
Hi,
Please help me, whenever i try to access my url for a post in Lumen through the browser i get the below error
Whoops, looks like something went wrong.
MethodNotAllowedHttpException
in RoutesRequests.php
at Application->handleDispatcherResponse(array(2, array('POST')))
in RoutesRequests.php
see code from web.php below
$router->post('gen','VoucherController@generateVoucherCode');
see code from generateVoucherCode
class VoucherController extends Controller
{
public function generateVoucherCode(Request $request){
// generate 16 digit random no.
$random1 = rand(1111, 9999);
$random2 = rand(1111, 9999);
$random3 = rand(1111, 9999);
$random4 = rand(1111, 9999);
$voucher_code = ($random1."-".$random2."-".$random3."-".$random4);
$today = date("Y-m-d");
$use_once = "yes";
$request->request->add( ['voucher_code' => $voucher_code,
'use_once' => $use_once,
'date_used' => $today,
'date_created' => $today]);
Voucher_code::create($request->all());
return response()->json($voucher_code);
}
Can you pls tell me what I am doing wrongly
Closing this issue because it's already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue.
i am experiencing this issue on any request on lumen
(1/1)聽NotFoundHttpException
--
in聽RoutesRequests.php聽line 314
@hayjay
I am facing same issue, did you find any work around?
@indiraJeldi how did you served the lumen application, did you used a command like php -S localhost:port -t public?
@indiraJeldi how did you served the lumen application, did you used a command like php -S localhost:port -t public?
@hayjay ,
It just worked for me, by doing this two changes, I didnt use the command
@hayjay Lumen is like Laravel, I am not sure about your question. You want to serve it just for development or production? For development you can use php -S localhost:8000 -t public but for production you can either use Apache or Nginx web servers.
@sereysethy I was able to fix my issue then, and i also have a lumen application on apache server.
I was only trying to know how @indiraJeldi was serving the application locally.
Anyways, thanks for the reply @sereysethy.
@hayjay @sereysethy ,
I have lumen applicaiton on apache server.
Most helpful comment
@hayjay ,
It just worked for me, by doing this two changes, I didnt use the command
$app->run() with
$request = Illuminate\Http\Request::capture();
$app->run($request);