- Rudra\Router\Attributes\Middleware
- Rudra\Router\Attributes\Routing
- Rudra\Router\Router
- Rudra\Router\RouterFacade
- Rudra\Router\RouterInterface
- Rudra\Router\Traits\RouterAnnotationTrait
- Rudra\Router\Traits\RouterRequestMethodTrait
| Visibility | Function |
|---|---|
| public | __construct(string $name, ?string $params) |
| Visibility | Function |
|---|---|
| public | __construct(string $url, array|string $method) |
| Visibility | Function |
|---|---|
| public | set(array $route): voidSets the route, parsing HTTP methods (if multiple are specified via |). Registers a route handler for each method. |
| private | handleRequestUri(array $route): voidProcesses the incoming URI request and checks if it matches the current route. |
| private | handleRequestMethod(): voidProcesses the HTTP request method, including spoofing via _method (for PUT/PATCH/DELETE) |
| private | handlePattern(array $route, array $request): arrayMatches the URI from the route with the actual request, processing parameters of the form :param and :regexp. This method is used to extract dynamic segments from a URI pattern |
| private | setCallable(array $route, ?array $params): voidCalls the controller associated with the route — either a Closure or a controller method. |
| public | directCall(array $route, ?array $params): voidCalls the controller and its method directly, performing the full lifecycle: This method is used to fully dispatch a route after matching it with the current request. |
| private | callActionThroughReflection(?array $params, string $action, object $controller): voidCalls the controller method using Reflection, performing automatic parameter injection based on type hints. This method is typically used when the zend.exception_ignore_args setting is enabled, allowing for more flexible and type-safe dependency resolution. |
| private | callActionThroughException(?array $params, string $action, object $controller): voidCalls the specified controller method directly. If the argument type or number does not match — tries to automatically inject required dependencies. This is a fallback mechanism for cases where Reflection-based injection is disabled or unavailable. Handles two types of errors during invocation: - \ArgumentCountError — thrown when the number of arguments doesn't match the method signature. - \TypeError — thrown when an argument is not compatible with the expected type. In both cases, Rudra's autowire system attempts to resolve and inject the correct dependencies. |
| public | handleMiddleware(array $chain): voidExecutes a chain of middleware, recursively calling each element. Middleware can be specified in one of the supported formats: - 'MiddlewareClass' (string) — a simple class name to call without parameters. - ['MiddlewareClass'] (array with class name) — same as above, allows for future extensions. - ['MiddlewareClass', $parameter] (array with class and parameter) — passes the parameter to the middleware. Each middleware must implement the __invoke() method to be callable. |
| public | annotationCollector(array $controllers, bool $getter, bool $attributes): ?arrayCollects and processes annotations from the specified controllers. This method scans each controller class for Routing and Middleware annotations, builds route definitions based on those annotations, and either: - Registers them directly via set() (if $getter = false), or- Returns them as an array (if $getter = true). |
| protected | handleAnnotationMiddleware(array $annotation): arrayProcesses middleware annotations into a valid middleware format. #[Middleware(name: "Auth", params: "admin")]to: ['Auth', 'admin'] |
| public | __construct(Rudra\Container\Interfaces\RudraInterface $rudra) |
| public | rudra(): Rudra\Container\Interfaces\RudraInterface |
| public | get(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the GET HTTP method. |
| public | post(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the POST HTTP method. |
| public | put(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the PUT HTTP method. |
| public | patch(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the PATCH HTTP method. |
| public | delete(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the DELETE HTTP method. |
| public | any(string $pattern, callable|array $target, array $middleware): voidRegisters a route that supports all HTTP methods. Sets the method to a pipe-separated string ('GET|POST|PUT|PATCH|DELETE'), allowing the same route to handle multiple request types. |
| public | resource(string $pattern, string $controller, array $actions): voidRegisters a resource route, mapping standard actions to controller methods. Supports common CRUD operations by default: - GET=> read - POST => create - PUT=> update - DELETE => delete Can be customized with an optional $actions array. |
| protected | setRoute(string $pattern, $target, string $httpMethod, array $middleware): voidThe method constructs a route definition and passes it to the set() method for registration. |
| Visibility | Function |
|---|---|
| public static | __callStatic(string $method, array $parameters): mixedHandles static method calls for the Facade class It dynamically resolves the underlying class name by removing "Facade" from the class name If the resolved class does not exist, it attempts to clean up the class name by removing spaces If the resolved class is not already registered in the container, it registers it Finally, it delegates the static method call to the resolved class instance |
| Visibility | Function |
|---|---|
| abstract public | set(array $route): void |
| abstract public | directCall(array $route, ?array $params): void |
| Visibility | Function |
|---|---|
| public | annotationCollector(array $controllers, bool $getter, bool $attributes): ?arrayCollects and processes annotations from the specified controllers. This method scans each controller class for Routing and Middleware annotations, builds route definitions based on those annotations, and either: - Registers them directly via set() (if $getter = false), or- Returns them as an array (if $getter = true). |
| protected | handleAnnotationMiddleware(array $annotation): arrayProcesses middleware annotations into a valid middleware format. #[Middleware(name: "Auth", params: "admin")]to: ['Auth', 'admin'] |
| Visibility | Function |
|---|---|
| public | get(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the GET HTTP method. |
| public | post(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the POST HTTP method. |
| public | put(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the PUT HTTP method. |
| public | patch(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the PATCH HTTP method. |
| public | delete(string $pattern, callable|array $target, array $middleware): voidRegisters a route with the DELETE HTTP method. |
| public | any(string $pattern, callable|array $target, array $middleware): voidRegisters a route that supports all HTTP methods. Sets the method to a pipe-separated string ('GET|POST|PUT|PATCH|DELETE'), allowing the same route to handle multiple request types. |
| public | resource(string $pattern, string $controller, array $actions): voidRegisters a resource route, mapping standard actions to controller methods. Supports common CRUD operations by default: - GET=> read - POST => create - PUT=> update - DELETE => delete Can be customized with an optional $actions array. |
| protected | setRoute(string $pattern, $target, string $httpMethod, array $middleware): voidThe method constructs a route definition and passes it to the set() method for registration. |