Skip to content

Routing

tuxnull edited this page May 31, 2025 · 1 revision

Routing

VeloFrame uses a simple but powerful routing system to map URLs to your page controllers.


How Routing Works

  • All requests are routed to index.php.
  • The framework auto-discovers controllers in the pages/ directory (if enabled).
  • Each controller can define one or more routes using special comments.

Defining Routes

Add a # @route /your-path annotation at the top of your controller file:

// pages/AboutHandler.php
# @route /about
class AboutHandler extends DefaultPageController {
    // ...
}

You can define multiple routes per controller by adding more # @route lines.


Custom Routing

  • Use RoutingHandler to manually register routes if you want full control.
  • Example:
$rh = new RoutingHandler();
$rh->register('/custom', new CustomHandler());
$server->setRoutingHandler($rh);

Route Parameters

Currently, VeloFrame supports static routes. For dynamic parameters, extend the routing logic in your controllers.


Tips

  • Keep route paths clean and RESTful.
  • Use one controller per logical page or endpoint.

See Architecture for the full request flow.

Clone this wiki locally