Codeigniter 4 - how to show 404 page?

Viewed 7307

It's a very silly question but I can't handle it :) In Codeigniter 3, I just used show_404() function in any controller to show 404 page. How could I do the same with Codeigniter 4?

2 Answers

I was looking just now exactly for the same thing. I found here the solution: CodeIgniter 4 User Guide - Error Handling

In your controller, simply write:

throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
Related