It lives
Just to show that the toy MVC is fully functional, here is the bit of code that simulates a single hit to the home page:
src/Part3/Chapter8/toy_mvc.php
Repo: https://git.io/JRw53
<?php declare(strict_types=1); namespace Book\Part3\Chapter8; use Book\Part3\Chapter8\ToyMVC\BrowserVisit; require __DIR__ . '/../../../vendor/autoload.php'; $homePage = (new BrowserVisit())->visit('/'); echo $homePage;
Output:
To simulate the browser, we have a simple class called BrowserVisit
:
src/Part3/Chapter8/ToyMVC/BrowserVisit.php
Repo:
<?php declare(strict_types=1); namespace Book\Part3\Chapter8\ToyMVC; /** * This class lets us very simply simulate a browser visiting our toy MVC app. */ final class BrowserVisit { private FrontController $frontController; public function __construct() { $this-...