alxarafe/resource-twig

This package is abandoned and no longer maintained. The author suggests using the alxarafe/resource-controller package instead.

Twig adapter for alxarafe/resource-controller. Provides a RendererContract implementation using Twig for flexible and decoupled template rendering.

Maintainers

Package info

github.com/alxarafe/resource-twig

pkg:composer/alxarafe/resource-twig

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-04-24 08:04 UTC

This package is auto-updated.

Last update: 2026-04-24 08:14:36 UTC


README

Warning

DEPRECATED AND OBSOLETE

This package has been deprecated and its functionality has been natively integrated into resource-controller via the DefaultRenderer and static HTML templates. You no longer need this package. Please remove it from your dependencies.

PHP Version CI Tests Static Analysis PRs Welcome

Twig adapter for alxarafe/resource-controller.

Provides a RendererContract implementation using Twig for flexible and decoupled template rendering.

Ecosystem

Package Purpose Status
resource-controller Core CRUD engine + UI components ✅ Stable
resource-eloquent Eloquent ORM adapter ✅ Stable
resource-blade Blade template renderer adapter ✅ Stable
resource-twig Twig template renderer adapter ✅ Stable

Installation

composer require alxarafe/resource-twig

This will also install alxarafe/resource-controller as a dependency.

Usage

use Alxarafe\ResourceTwig\TwigRenderer;

// Create a renderer with template paths
$renderer = new TwigRenderer(
    templatePaths: [__DIR__ . '/templates'],
    cachePath: __DIR__ . '/cache/twig',    // false to disable caching
    debug: false
);

// Render a template (auto-appends .html.twig if no extension)
echo $renderer->render('products/index', [
    'title' => 'Products',
    'items' => $products,
]);

// Add additional template paths at runtime
$renderer->addTemplatePath(__DIR__ . '/module-templates');

Template example

{# templates/products/index.html.twig #}
<h1>{{ title }}</h1>
<ul>
{% for item in items %}
    <li>{{ item.name }} — {{ item.price }}</li>
{% endfor %}
</ul>

Development

Docker

docker compose up -d
docker exec alxarafe-resources composer install

Running the CI pipeline locally

bash bin/ci_local.sh

Running tests only

bash bin/run_tests.sh

License

GPL-3.0-or-later