Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Glynn Theme Bundle Laravel Package

disjfa/glynn-theme-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require disjfa/glynn-theme-bundle
    

    Ensure your project uses Symfony 4+ (compatible with Laravel via Symfony Bridge or standalone).

  2. 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.

  3. 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).


Implementation Patterns

Workflows

  1. Template Overrides:

    • Override any @GlynnTheme/ template by creating a matching file in your project’s templates/ directory.
    • Example: Customize the navbar by extending @GlynnTheme/admin/navbar.html.twig.
  2. Asset Integration:

    • Use the bundle’s CSS/JS via Twig’s asset() function (Symfony) or Laravel’s asset() helper.
    • Example:
      <link rel="stylesheet" href="{{ asset('@GlynnTheme/css/admin.css') }}">
      
  3. Dynamic Theming:

    • Pass variables to templates via Twig’s {{ dump() }} or Symfony’s render() with context.
    • Example (Symfony controller):
      return $this->render('admin/dashboard.html.twig', [
          'user' => $user,
      ]);
      
  4. Laravel-Specific Bridge:

    • Use 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',
      ],
      

Integration Tips

  • Glynn Admin Compatibility: Pair with glynn-admin-symfony4 for full admin panel features.
  • Laravel Routing: Ensure routes in routes/web.php target Twig templates (e.g., Route::get('/admin', 'AdminController@index')->name('admin.dashboard')).
  • Asset Pipeline: Use Laravel Mix/Vite to compile Glynn’s assets if needed (e.g., SCSS preprocessing).

Gotchas and Tips

Pitfalls

  1. Template Path Conflicts:

    • If overriding templates, ensure your project’s templates/ directory takes precedence. Symfony’s twig.config.path or Laravel’s Twig bridge config must prioritize your paths.
    • Debug with php bin/console debug:twig (Symfony) or check Twig’s loaded paths.
  2. Asset Paths:

    • Glynn’s assets are served from @GlynnTheme/. In Laravel, verify the public_path() or asset() helper resolves correctly (e.g., asset('vendor/disjfa/glynn-theme-bundle/public/css/admin.css')).
  3. Symfony Dependency:

    • The bundle assumes Symfony’s Twig/Symfony components. In Laravel, ensure:
      • symfony/twig-bridge is installed.
      • The Twig_Environment is properly bootstrapped (e.g., via Laravel’s AppServiceProvider).
  4. Caching:

    • Clear Twig cache after template changes:
      php bin/console cache:clear  # Symfony
      php artisan view:clear      # Laravel (if using Twig bridge)
      

Debugging

  • Template Not Found: Use {% debug %} in Twig to inspect loaded templates.
  • CSS/JS 404s: Check the browser’s Network tab for incorrect asset paths. Verify asset() resolves to the correct vendor path.

Extension Points

  1. Custom Twig Extensions:

    • Extend Glynn’s functionality by creating custom Twig filters/functions. Example:
      // src/Twig/AppExtension.php
      class AppExtension extends \Twig\Extension\AbstractExtension {
          public function getFunctions() {
              return [
                  new \Twig\TwigFunction('custom_glynn_filter', [$this, 'customFilter']),
              ];
          }
      }
      
  2. Dynamic Theme Switching:

    • Use environment variables or config to toggle between Glynn and custom themes:
      // config/glynn.php
      'theme' => env('THEME', 'glynn'),
      
    • Conditionally extend templates in Twig:
      {% if app.config.theme == 'glynn' %}
          {% extends "@GlynnTheme/admin.html.twig" %}
      {% else %}
          {% extends "admin/custom.html.twig" %}
      {% endif %}
      
  3. Laravel Blade Integration:

    • Use @include directives to embed Glynn templates in Blade:
      @include('twig::admin/navbar', ['user' => $user])
      
    • Requires twig/blade-bridge or custom Twig-Blade integration.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky