I installed lumen by composer
global require "laravel/lumen-installer"
add the code in reoutes/web.php file
$router->get('/', function () use ($router) {
return response()->json(['test' => 1], 500);
});
I think http response status code will return 500 but always return 200

I tested a nonexistent url http response still returns code 200

Please tell me how to set the http status code, thanks
edit code in routes/web.php
$router->get('/', function () use ($router) {
return response()->json(['test' => 1], 500);
});
Hi there,
Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:
However, this issue will not be locked and everyone is still free to discuss solutions to your problem!
Thanks.
I had the same issue on my app (Lumen 6.4) and believe me or not the issue was a extra blank line at the top of my app.php.
<?php
require_once __DIR__.'/helpers.php';
require_once __DIR__.'/../vendor/autoload.php';
So I just removed it:
<?php
require_once __DIR__.'/helpers.php';
require_once __DIR__.'/../vendor/autoload.php';
And everything was working like a charm!!
@dericlima Thanks, in my case, the extra blank line was in the routes/web.php
How did you catch this empty error?
Most helpful comment
I had the same issue on my app (Lumen 6.4) and believe me or not the issue was a extra blank line at the top of my
app.php.So I just removed it:
And everything was working like a charm!!