Skip to content

Tools Layer – API Reference ​

Namespace: Alxarafe\Tools

Infrastructure tools for request dispatching, debugging, module management, and dependency resolution.


Dispatcher ​

Namespace: Alxarafe\Tools\Dispatcher
Source: [Dispatcher.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/Dispatcher.php)

Main entry point for the framework. Initializes constants, translation system, and routes to the appropriate dispatcher.

Constants ​

ConstantValueDescription
MODULE'module'GET parameter name for module
CONTROLLER'controller'GET parameter name for controller

Methods ​

MethodSignatureDescription
run()static run(array $alternative_routes = []): voidBootstrap and dispatch. Detects API vs Web request and delegates.

WebDispatcher ​

Namespace: Alxarafe\Tools\Dispatcher\WebDispatcher
Extends: Dispatcher
Source: [WebDispatcher.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/Dispatcher/WebDispatcher.php)

Handles web requests: route resolution, controller instantiation, theme/language resolution, template path setup, and error handling.

Methods ​

MethodSignatureDescription
dispatch()static dispatch(string $defaultModule, string $defaultController, string $defaultAction): boolFull lifecycle entry point with path setup, route loading, and error handling.
run()static run(string $module, string $controller, string $method): boolCore dispatch: resolve controller from routes, instantiate, configure templates, call method.

Error Handling ​

  1. First failure → Redirect to ErrorController
  2. Loop guard → If already in error state, render raw HTML directly
  3. Emergency → Minimal styled error page with 500 status

ApiDispatcher (Tools) ​

Namespace: Alxarafe\Tools\Dispatcher\ApiDispatcher
Source: [ApiDispatcher.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/Dispatcher/ApiDispatcher.php)

Handles API requests: parses the URL path, matches to API controllers, validates JWT, and returns JSON.


Debug ​

Namespace: Alxarafe\Tools\Debug
Source: [Debug.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/Debug.php)

Integrates PHP DebugBar for development. Provides message logging and header/footer rendering.

Methods ​

MethodSignatureDescription
initialize()static initialize(bool $reload = false): voidInitializes DebugBar if debug mode is enabled in config.
message()static message(string $msg): voidLogs a debug message to DebugBar (no-op if debug disabled).
getDebugBar()static getDebugBar(): ?DebugBarReturns the DebugBar instance or null.
getRenderHeader()static getRenderHeader(): stringReturns DebugBar CSS/JS includes.
getRenderFooter()static getRenderFooter(): stringReturns DebugBar JS initialization.

ModuleManager ​

Namespace: Alxarafe\Tools\ModuleManager
Source: [ModuleManager.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/ModuleManager.php)

Scans module directories, reads #[ModuleInfo] attributes, and builds the navigation menu arrays.

Methods ​

MethodSignatureDescription
getArrayMenu()static getArrayMenu(): arrayReturns top-level menu items from all modules.
getArraySidebarMenu()static getArraySidebarMenu(): arrayReturns sidebar menu items from all modules.

DependencyResolver ​

Namespace: Alxarafe\Tools\DependencyResolver
Source: [DependencyResolver.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/DependencyResolver.php)

Builds a directed acyclic graph (DAG) of module dependencies by scanning use statements and #[RequireModule] attributes. Used to determine activation order and detect circular dependencies.


DebugBar Collectors ​

PhpCollector ​

Namespace: Alxarafe\Tools\DebugBarCollector\PhpCollector
Source: [PhpCollector.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/DebugBarCollector/PhpCollector.php)

Custom DebugBar collector for PHP environment information.

TranslatorCollector ​

Namespace: Alxarafe\Tools\DebugBarCollector\TranslatorCollector
Source: [TranslatorCollector.php](file:///home/rsanjose/Desarrollo/Alxarafe/alxarafe/src/Core/Tools/DebugBarCollector/TranslatorCollector.php)

Shows missing translation keys and loaded translation files in the DebugBar.