| 1234567891011121314151617181920 |
- <?php
- // Having an "autoloader" (see https://www.php.net/manual/en/language.oop5.autoload.php) allows us to just
- // use classes without having to worry where exactly those PHP files are located. This particular autoloader
- // is extremely simple.
- require_once __DIR__ . "/autoloader.php";
- AutoLoader::registerLoader();
- Router::scan("routes/*.php");
- $route = Router::findRoute($_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"]);
- var_dump($route);
- // Since we now have an autoloader, we can just "use" the PageContext class and the autloader will actually
- // find and load it. The page context represents all the contextual information that we have in our current
- // request and we use it to define our page rendering mechanism. This mechanism is mostly based on some
- // very simple conventions for where certain types of files are placed.
- $context = new PageContext($_SERVER["REQUEST_URI"]);
- // We just call "render" which will do the rest for us.
- $context->render();
|