Installation:
composer require disjfa/glynn-theme-bundle
Ensure your project uses Symfony 4+ (compatible with Laravel via Symfony Bridge or standalone).
Enable the Bundle:
Add to config/bundles.php (Symfony) or register via AppKernel (if using standalone Symfony). For Laravel, use a service provider wrapper if needed.
First Use Case:
Extend the base admin template in your project’s templates/ directory:
{# templates/admin/base.html.twig #}
{% extends "@GlynnTheme/admin.html.twig" %}
Place this file in a location Twig can auto-discover (e.g., resources/views/admin/base.html.twig in Laravel, with proper Twig bridge setup).
Template Overrides:
@GlynnTheme/ template by creating a matching file in your project’s templates/ directory.@GlynnTheme/admin/navbar.html.twig.Asset Integration:
asset() function (Symfony) or Laravel’s asset() helper.<link rel="stylesheet" href="{{ asset('@GlynnTheme/css/admin.css') }}">
Dynamic Theming:
{{ dump() }} or Symfony’s render() with context.return $this->render('admin/dashboard.html.twig', [
'user' => $user,
]);
Laravel-Specific Bridge:
symfony/twig-bridge to integrate Twig with Laravel’s Blade. Example in config/twig.php:
'paths' => [
__DIR__.'/../resources/views',
__DIR__.'/../vendor/disjfa/glynn-theme-bundle/templates',
],
glynn-admin-symfony4 for full admin panel features.routes/web.php target Twig templates (e.g., Route::get('/admin', 'AdminController@index')->name('admin.dashboard')).Template Path Conflicts:
templates/ directory takes precedence. Symfony’s twig.config.path or Laravel’s Twig bridge config must prioritize your paths.php bin/console debug:twig (Symfony) or check Twig’s loaded paths.Asset Paths:
@GlynnTheme/. In Laravel, verify the public_path() or asset() helper resolves correctly (e.g., asset('vendor/disjfa/glynn-theme-bundle/public/css/admin.css')).Symfony Dependency:
symfony/twig-bridge is installed.Twig_Environment is properly bootstrapped (e.g., via Laravel’s AppServiceProvider).Caching:
php bin/console cache:clear # Symfony
php artisan view:clear # Laravel (if using Twig bridge)
{% debug %} in Twig to inspect loaded templates.asset() resolves to the correct vendor path.Custom Twig Extensions:
// src/Twig/AppExtension.php
class AppExtension extends \Twig\Extension\AbstractExtension {
public function getFunctions() {
return [
new \Twig\TwigFunction('custom_glynn_filter', [$this, 'customFilter']),
];
}
}
Dynamic Theme Switching:
// config/glynn.php
'theme' => env('THEME', 'glynn'),
{% if app.config.theme == 'glynn' %}
{% extends "@GlynnTheme/admin.html.twig" %}
{% else %}
{% extends "admin/custom.html.twig" %}
{% endif %}
Laravel Blade Integration:
@include directives to embed Glynn templates in Blade:
@include('twig::admin/navbar', ['user' => $user])
twig/blade-bridge or custom Twig-Blade integration.How can I help you explore Laravel packages today?