mini\Router\Reroute
class
Documentation
Exception for pattern-based routing in DEFAULT.php files
Allows DEFAULT.php to define routing patterns for its directory scope. The Router will match the current path against patterns and resolve the target.
Only valid when thrown from DEFAULT.php files. Patterns are relative to the directory containing the DEFAULT.php.
Pattern targets can be:
- string: Request path (Router will resolve to file)
- Closure: Invoked with path parameters, returns request path string
- ResponseInterface: Direct response (future)
- RequestHandlerInterface: PSR-15 handler (future)
IMPORTANT: Targets are REQUEST PATHS, not filenames!
Router resolves them: _view?id=123 → tries [_view.php, __DEFAULT__.php]
Examples:
// _routes/users/__DEFAULT__.php
throw new Reroute([
'/{id}/' => fn($id) => "_view?id=$id", // → resolves to _view.php
'/{id}/edit' => '_edit', // → resolves to _edit.php
'/create' => '_create', // → resolves to _create.php
'/' => '_index', // → resolves to _index.php
]);
// _routes/blog/__DEFAULT__.php
throw new Reroute([
'/{slug}/' => fn($slug) => "_post?slug=$slug", // → resolves to _post.php
'/' => 'index', // → resolves to blog/index.php
]);
Security: Can route to underscore-prefixed files (internal routing).
Inheritance
Extends: RuntimeException
Implements:
Stringable
Throwable
Properties (5)
array $routes
$message
$code
string $file
int $line
Methods (10)
Documentation missing
public
__wakeup()
inherited from Exception
Documentation missing
public
final
getMessage()
inherited from Exception
Documentation missing
public
final
getCode()
inherited from Exception
Documentation missing
public
final
getFile()
inherited from Exception
Documentation missing
public
final
getLine()
inherited from Exception
Documentation missing
public
final
getTrace()
inherited from Exception
Documentation missing
public
final
getPrevious()
inherited from Exception
Documentation missing
public
final
getTraceAsString()
inherited from Exception
Documentation missing
public
__toString()
inherited from Exception
Documentation missing