Currently, I am working on a project in Laravel 8. for this I want to make some custom error pages specifically a 404 and a 500 page. I want to visit these pages via http://127.0.0.1:8000//404 or http://127.0.0.1:8000//500 so I can showcase them. Now I am able to get the 404 page to show with http://127.0.0.1:8000/404 but not the 500 page. And I am unable to find sources on the internet that go into this regarding Larvel 8.
Is there anyone here that knows how I will be able to manage this? It would be a great help!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Just create a route for it and return the status code.
Route::get('/500', fn() => abort(500));
Method 2
Adding custom pages for errors will not simply override the existing error templates. First, you need to publish Laravel’s default error page templates using the vendor:publish
Artisan command. Once the templates have been published, you may customize them to your liking:
php artisan vendor:publish --tag=laravel-errors
You can add temporary routes as @Daan said to view the error pages.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0