Let's start
by creating the easiest of the controllers: the ErrorController
. This controller does not do much;
it just renders the error.twig
template
sending the "Page not found!" message. As you might remember, the
router uses this controller when it cannot match the request to any
of the other defined routes. Save the following class in
src/Controllers/ErrorController.php
:
<?php namespace Bookstore\Controllers; class ErrorController extends AbstractController { public function notFound(): string { $properties = ['errorMessage' => 'Page not found!']; return $this->render('error.twig', $properties); } }