Presentation

UI Components

Presentation blocks reutilizables registrados mediante service providers y expuestos vía ComponentRegistry.

What UI Components are for

ComponentRegistry is the shared registry for reusable UI/application components. Framework automatically registers breadcrumb, pagination and meta. Applications can register additional components through config and resolve them from the same registry.

How they are wired

ComponentServiceProvider delegates built-in wiring to BreadcrumbServiceProvider, PaginationServiceProvider and MetaServiceProvider, then builds ComponentRegistry with built-ins and app-defined components from ComponentConfig.

example.php
$this->registerBreadcrumb($container);
$this->registerPagination($container);
$this->registerMeta($container);
$this->registerRegistry($container);

Component registry contract

ComponentRegistry maps names to classes and resolves instances via DI. Built-ins expose explicit typed accessors (breadcrumb(), pagination(), meta()). Custom components are resolved via get(name, ExpectedClass::class). Unknown names and wrong expected type throw clear RuntimeException.

example.php
$components = $container->get(ComponentRegistry::class);

$breadcrumb = $components->breadcrumb();
$pagination = $components->pagination();
$meta = $components->meta();

Custom component registration

Register app components in app/Config/Components.yaml. The YAML payload is validated and converted into typed ComponentConfigDefinition before ComponentRegistry is built. Existing demo app contains App\Component\NavigationComponent and resolves it through typed lookup.

example.php
module: components
config:
  navigation: App\Component\NavigationComponent

Custom component usage

Once the component is registered, resolve it from ComponentRegistry with an explicit expected type.

example.php
$components = $container->get(ComponentRegistry::class);
$navigation = $components->get('navigation', NavigationComponent::class);
$items = $navigation->items();

Validation and overrides

Config validation rules: component name must be a non-empty string and value must be an existing class-string. Custom registration may intentionally override a default component name (for example pagination) when replacement is API-compatible.

Built-in component pages

System components are documented on dedicated subpages with API and examples: Breadcrumb, Pagination and Meta.

Template usage

Views get component shared from ViewServiceProvider. Built-ins can use typed accessors. Custom components do not use dynamic methods and do not use __call(); resolve them via get(name, ExpectedClass::class).

example.php
<?= $component->breadcrumb()->render($trail ?? null) ?>
<?= $component->pagination()->render($pagination ?? null) ?>
<?= $component->meta()->render($metaData) ?>