Search by

juaniquillo / base-backend-component

juaniquillo

Framework-agnostic base state for backend components: attributes, contents, settings, themes, paths and array serialization. You choose how your components render.

Package info

github.com/juaniquillo/base-backend-component

pkg:composer/juaniquillo/base-backend-component

Statistics

Installs: 42

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-11 16:38 UTC

This package is auto-updated.

Last update: 2026-11-11 16:53:42 UTC


README

CI

Framework-agnostic base state for backend components: attributes, contents, settings, themes, paths and array serialization. You choose how your components render (templates, plain strings, JSON, or anything else), and implement that part in your own package.

Install

composer require juaniquillo/base-backend-component

Requires PHP ^8.3.

Use

use Juaniquillo\BaseBackendComponent\BaseBackendComponent;
use Juaniquillo\BaseBackendComponent\Themes\GenericThemeManager;

$component = new BaseBackendComponent(
    'button',
    new GenericThemeManager(__DIR__.'/themes'),
);

$component
    ->setAttribute('id', 'save')
    ->setContent('Save')
    ->setTheme('action', 'success')
    ->setSetting('transition', 'fade');

$array = $component->toArray();

Restore later with:

use Juaniquillo\BaseBackendComponent\Deserializers\ComponentDeserializer;

$restored = ComponentDeserializer::fromArray($array);

Theme files are plain PHP files returning arrays (default extension .php, configurable through setThemeExtension()):

// themes/action.php
return [
    'default' => 'bg-blue-700 hover:bg-blue-800',
    'success' => 'bg-green-700 hover:bg-green-800',
];

Non-goals

This package never renders. There is no toHtml(), no renderable interface, no template engine and no framework integration. Rendering, render caching and framework wiring belong to the package that consumes this state. The only cache primitives here are framework-free: the Cache contract, DefaultCache, and the PSR-16 FileCache.

Building on it

Every concrete class in this package is final and is meant as a blueprint. Do not extend them. Compose the traits under Concerns\ into your own classes and implement only the contracts you need.

See docs/implementing-a-package.md for the full guide: contract and trait reference, worked examples for components, attribute bags, contents, themes, serialization, render caching, pitfalls and a test checklist.

Develop

composer install
composer test
composer run coverage:check
composer analyse
composer run format:check
composer run rector:check
composer qa

The suite must keep 100% statement coverage. composer qa:ci runs the same checks plus the coverage gate, which is what CI executes.

License

MIT. See LICENSE.md.