| | |
| | | declare(strict_types= 1); |
| | | |
| | | define ("ROOT_PATH", dirname(__DIR__)); |
| | | |
| | | spl_autoload_register(function ($class) { |
| | | require ROOT_PATH . "/src/". str_replace("\\", "/", $class). ".php"; |
| | | }); |
| | |
| | | set_exception_handler("Framework\ErrorHandler::handleException"); |
| | | |
| | | |
| | | $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
| | | if ($path === false) { |
| | | throw new UnexpectedValueException("Malformed URL: {$_SERVER["REQUEST_URI"]}"); |
| | | } |
| | | |
| | | $segments = explode("/", $path); |
| | | |
| | | $router = require ROOT_PATH . "/config/routes.php"; |
| | | |
| | | $container = require ROOT_PATH . "/config/services.php"; |
| | | |
| | | $dispatcher = new Framework\Dispatcher($router, $container); |
| | | |
| | | $dispatcher->handle($path, $_SERVER["REQUEST_METHOD"]); |
| | | $request = Framework\Request::createFromGlobals(); |
| | | |
| | | $dispatcher->handle($request); |
| | | |