EDDYMENS

Published 1 week from now

How To Override The Default 404 Error Page In Laravel 12

Table of contents

Once of the first things I quickly tweak whenever I start a new Laravel project is to override the error pages to match the theme of my project. However, from time to time, Laravel changes how error handling is dealt with between versions.

I have had to do this for my recent project which runs on Laravel 12, and I figured I might as well write about it to meet my monthly writing target.

So here goes.

Thankfully, the process has become much simpler over time.

Step 1.

Creating an errors directory in the resources/views folder

Creating the errors directory using the terminal

$ mkdir resources/view/errors

You can also do this using your operating system's file explorer.

Step 2

Inside the newly created errors directory, create a 404.blade.php view. This is the page that will be shown whenever your app throws a 404 error.

Similarly, adding a 500.blade.php file will handle all 500-level errors.

Conclusion

Thats its, once you create the errors directory and add the respective view files, you should be good to go.

Here is another article you might like 😊 Fetch And Update Yahoo Finance Data In Excel