Laravel 5.1 random 404 errors - laravel

I am using laravel 5.1 framework, I have set up my site using WAMP.
I have handled the errors whoops as it is giving response header except 200 OK.
Now the problem here is,
sometimes existing routes [i.e. working the very next moment if I try] return 404 page with response header 200 OK.
I am unable to figure it out that in which case it is returning 404 page.
Note that I have my own 404 page designed which I found in the response.
My controller code is as below:
public function create($program_id)
{
$projects = $this->mock->mockprojectlist($program_id);
return view('mocks.create', compact('program_id', 'projects'));
}
Can anyone help me with this?

Related

Laravel api - 405 not allowed shared hosting

I'm new to Laravel and i have the next problem.
I have an API POST route that works properly in the localhost. I send POST requests from POSTMAN:
Route::group(['middleware' => 'api_import'], function () {
Route::get('/products', [ArticlesController::class, 'index']);
Route::post('/products', [ArticlesController::class, 'addOrUpdateArticles']);
Route::post('/categories', [CategoriesController::class, 'addOrUpdateCategories']);
});
However, it will not work on hosting. Hosting is shared, and I get the message:
When json contains a couple of products everything works properly. When json contains a complete table of 3500 products I get this error.
It is possible that there is a redirect on the page. You should confirm this through the network tab in your browser, because any POST request with a redirect is considered a GET request, so an error appears (405 Method Not Allowd)

Why Laravel reply 200 http code when MethodNotAllowedHttpException?

Why Laravel reply 200 http code when MethodNotAllowedHttpException?
I Would like to recieve a diferent code, like 500.
I consume laravel routes using angular or postman, and recieve 200 code and is dificult to deal with this.
Below one example:
This is not a error, but the usage of the dd() dump and die helper method. This will always return a 200.
Find all dd(); methods in your project and it should work and return a proper error code. But secondly due to that error being thrown, it could seem like your url is invalid and or not allowing POST calls.

Laravel 5.2 Incorrect Route Model Binding does not show 404

In Laravel 5.2 docs about Implicit route model binding, there is written:
If a matching model instance is not found in the database, a 404 HTTP
response will be automatically generated.
Route:
Route::get('/product/{product}',function(Product $product){
dd($product);
});
When I enter into URL parameter existent ID, everything works as expected. But when I enter into URL nonexistent product ID, I got No query results for model [App\Product]. instead of response 404. Any ideas why?
After searching i found out solution. If you have no specified error template files in resources/views/errors default Laravel message will be shown. Just create 404.blade.php file in resources/views/errors.

Laravel 4 : why did I get 2 different of 404 error page?

I'm using Laravel 4.2 framework for my website, and want it catch my 404 error correctly. My problem is that the server return a different 404 page when I try to open some bad link inside the public folder. Please give me some advice, thank you very much.
Folder structure:
-- app
-- bootstrap
-- public
--assets
--packagespage
-- vender
Normally, I set my 404 page like this:
When I tried http://localhost:8000/assets/some-name and http://localhost:8000/packages/some-name => new 404 page here:

Codeigniter http request and 404

I have a problem with Codeigniter.
This is my code:
http://pastebin.com/scccVP8D
If my url is: example.com/validator/validator/value/323445
Http request response:
323445
404 Page Not Found
The page you requested was not found.
Why do i get an error 404?
I don't see value/323445 anywhere in your code. You just have function validator without any parameter.
So, when you call example.com/validator/validator/value/323445 the page don't egsist.
You need to delete parameter or to add parameter in function and to use it.

Resources