We have introduced the Twig template engine to CodeIgniter 4.
The template folder has been changed directly under the project folder(/templates).
The 404 error page has been replaced.
$routes->set404Override('App\Controllers\Template::notFound')
App\Controllers\Template
//...
class Template extends BaseController
{
// ...
public function notFound ()
{
return $this->twig->display('errors/custom404'); // <- /templates/errors/custom404.twig
}
And in production, other errors are reading the production.php file (/app/Views/errors/html/production.php).
I also want to overwrite the exception handling page, what should I do?
Specifically, I want to load the production.twig file (/templates/errors/production.twig) instead of the production.php file (/app/Views/errors/html/production.php).
Is there a way to override the exception page like a 404 page controller?
vendor/codeigniter4/framework/system/Debug/Exceptions.php
I can see that production.php is hardcoded in the method determineView
, is it possible to override this method?
And is it okay to overwrite?