Routing
The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.
Documentation
# Routing
DBM Framework routes are built with Dbm\Routing\RouteBuilder. The framework example and DBM Platform use the same route model, but the platform has a fuller bootstrap and separate web/API route files.
# Framework example
In the DBM Framework repository, the runnable example keeps route definitions in example/bootstrap/routes.php. Its public entry point starts the example application and the route file returns a callback that receives RouteBuilder and DependencyContainer.
return function (RouteBuilder $routes, DependencyContainer $container): void {
$routes->get('/', [IndexController::class, 'index'], 'home');
};
This is a compact example of registering a route; it does not imply that every application must use one routes.php file.
# DBM Platform entry points
The platform HTTP entry point is public/index.php. It initializes runtime and autoloading, loads environment configuration, obtains the application factory from bootstrap/app.php, runs the Application, and emits the response.
bootstrap/app.php composes the container and services, boots modules, loads bootstrap/web.php, loads bootstrap/api.php inside a /api route group, registers module web routes, configures middleware, and returns the Application.
- bootstrap/web.php contains web routes such as /docs and /download.
- bootstrap/api.php contains API routes. Since app.php wraps this file in /api, a path declared there as /crypto/market/{symbol} is externally reached as /api/crypto/market/{symbol}.
- Module web routes are registered from ModuleRegistry by the application bootstrap. API modules are separately registered in bootstrap/api.php when they implement ApiModuleInterface.
This is the same RouteBuilder API, composed for the needs of a larger modular platform.
# Define a route
$routes->get('/articles/{slug}', [ArticleController::class, 'show'], 'article.show');
$routes->post('/articles', [ArticleController::class, 'create'], 'article.create');
The handler is a controller class and method pair. RouteBuilder supports GET, POST, PUT, PATCH, DELETE, and any. Names are optional identifiers used by UrlGeneratorInterface.
# Groups, middleware, and permissions
$routes->group('/admin', function (RouteBuilder $routes): void {
$routes->get('/reports', [ReportController::class, 'index'], 'admin.reports');
}, [RequireAdminMiddleware::class]);
$routes->permission('admin.access', function () use ($routes): void {
$routes->get('/settings', [SettingsController::class, 'index'], 'admin.settings');
});
Groups apply a path prefix and attach middleware to nested routes. Permission groups store a permission on routes so security middleware can check it.
# Dispatch and action arguments
Router normalizes the URI, resolves the language, matches method and path, attaches the matched Route and route parameters as request attributes, resolves the controller and action, then invokes it.
ActionArgumentResolver supplies matched route parameters and casts built-in scalar types, can inject PSR ServerRequestInterface or an explicitly registered service, and uses defaults when present. It is not the same mechanism as constructor autowiring in DependencyContainer.
A known path requested with the wrong method raises MethodNotAllowedException; an unknown path raises RouteNotFoundException. UrlGeneratorInterface generates URLs from route names.
# Attribute routing status
RouteAttribute and AttributeRouteLoader exist in the source tree but are marked unfinished and are not the active registration path in DBM Platform. PHPDoc comments such as @routing are documentation hints; they do not register routes. Use RouteBuilder unless the application explicitly wires attribute loading.