bootstrap.php 972 B

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