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

Symfony Material Theme Laravel Package

double-star-systems/symfony-material-theme

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Package

    composer require double-star-systems/symfony-material-theme
    

    Ensure your composer.json includes the package under require.

  2. Enable the Theme Bundle Add the bundle to your config/bundles.php:

    return [
        // ...
        DoubleStarSystems\MaterialThemeBundle\MaterialThemeBundle::class => ['all' => true],
    ];
    
  3. Install Assets Run from your project root:

    php bin/console assets:install public
    

    This copies Materialize CSS/JS to public/build/.

  4. Configure Base Template Extend the theme’s base template (material_theme/base.html.twig) in your own template (e.g., templates/base.html.twig):

    {% extends 'material_theme/base.html.twig' %}
    
  5. First Use Case: Materialize Components Use Materialize components directly in Twig:

    <div class="card blue-grey darken-1">
        <div class="card-content white-text">
            <span class="card-title">Hello Material!</span>
        </div>
    </div>
    

Implementation Patterns

Workflows

  1. Twig Integration

    • Override partials (e.g., material_theme/partials/navbar.html.twig) in templates/material_theme/partials/.
    • Use {% block material_theme_content %} to inject custom content into the theme’s layout.
  2. Menu Integration (KnpMenuBundle) Configure menus in config/packages/knp_menu.yaml:

    knp_menu:
        twig:
            template: material_theme/partials/menu.html.twig
    

    Render menus in Twig:

    {{ knp_menu('main', {'rootLink': {'route': 'home'} }) }}
    
  3. Asset Management

    • Customize assets by overriding files in public/build/ (e.g., public/build/css/materialize.css).
    • Use Webpack Encore to extend/override JS/CSS if needed.
  4. Responsive Design Leverage Materialize’s grid system (e.g., col s12 m6) in Twig:

    <div class="row">
        <div class="col s12 m6">Column 1</div>
        <div class="col s12 m6">Column 2</div>
    </div>
    
  5. Dynamic Theming Pass variables to Twig to toggle classes (e.g., dark/light mode):

    {% if is_dark_mode %}
        <body class="dark-mode">
    {% else %}
        <body>
    {% endif %}
    

Gotchas and Tips

Pitfalls

  1. Asset Paths

    • Forgetting to run assets:install after updates will break CSS/JS links.
    • Fix: Add a post-update hook in composer.json:
      "scripts": {
          "post-update-cmd": "php bin/console assets:install public"
      }
      
  2. KnpMenuBundle Dependency

    • The theme assumes KnpMenuBundle is installed. If missing, menus will fail.
    • Fix: Install the bundle first:
      composer require knplabs/knp-menu-bundle
      
  3. Twig Block Conflicts

    • Overriding blocks (e.g., material_theme_content) without extending the parent template will break the layout.
    • Fix: Always use {% extends 'material_theme/base.html.twig' %}.
  4. Materialize JS Initialization

    • Some Materialize components (e.g., modals, dropdowns) require JS initialization.
    • Fix: Use the theme’s materialize_init.js or manually initialize:
      document.addEventListener('DOMContentLoaded', function() {
          M.Modal.init(document.querySelectorAll('.modal'));
      });
      
  5. Caching Issues

    • Twig cache may serve stale templates after theme updates.
    • Fix: Clear cache:
      php bin/console cache:clear
      

Tips

  1. Custom SCSS Extend Materialize’s SCSS by overriding public/build/scss/materialize.scss and recompiling with Webpack Encore.

  2. Lazy-Loading Defer non-critical JS (e.g., Materialize’s JS) to improve performance:

    <script src="build/js/materialize.js" defer></script>
    
  3. Dark Mode Use CSS variables for dynamic theming:

    <style>
        :root {
            --primary-color: {{ primary_color|default('#6200ee') }};
        }
    </style>
    
  4. Debugging

    • Check browser console for 404s on missing assets.
    • Use Symfony’s profiler to inspect Twig template rendering.
  5. Extending Components Create custom Twig components (e.g., templates/components/material_card.html.twig) and reuse them:

    {% include 'components/material_card.html.twig' with {
        'title': 'Custom Card',
        'content': 'Dynamic content here'
    } %}
    
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours