Skip to content

Internals Bootstrap Routes Default

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

bootstrap/routes/default.php

Framework Internals · Subsystem overview · Developer guide

Source: bootstrap/routes/default.php · Snapshot 8411f4287706.

Bootstrap scripts wire globals, constants and collaborators in a defined order. These files are executable entry points rather than a reusable class API.

Imports and dependencies

use context\Context;
use router\Router;
use \bootstrap\controllers\StorageController;

Execution and global state

The script below is executed by its caller. Constants, registered callbacks, global assignments, guards, included files and their order are preserved here. Unlike class methods, entry-point execution can start the CLI loop, route a request, emit output, or terminate the process.

<?php
use context\Context;
use router\Router;
use \bootstrap\controllers\StorageController;
require_once BASE_PATH . '/bootstrap/controllers/StorageController.php';

$controller = new StorageController();
$controller->setContext(new Context(BASE_PATH, "System", 0));

$request = $_SERVER['REQUEST_URI'] ?? '/';

$routes = [
    0 => new Router("/storage/{id}/{name}", "Index", $controller),
];

$requestPath = parse_url($request, PHP_URL_PATH);
if (is_string($requestPath) && str_starts_with($requestPath, '/awt_packages/')) {
    $segments = explode('/', substr($requestPath, strlen('/awt_packages/')));
    if (count($segments) >= 2) {
        $route = '/awt_packages/{package}';
        for ($i = 0; $i < count($segments) - 2; $i++) $route .= '/{resource' . $i . '}';
        $routes[] = new Router($route . '/{file}', 'Resource', $controller);
    }
}

return $routes;

Related types

Clone this wiki locally