Installation
composer require braunstetter/rock-bundle
Add to config/bundles.php:
return [
// ...
Braunstetter\RockBundle\RockBundle::class => ['all' => true],
];
Enable Twig Extensions
Ensure TwigBundle is installed and configured in config/packages/twig.yaml:
twig:
paths: ['%kernel.project_dir%/templates']
globals:
rock: '@rock'
Basic Integration
Extend the base template in templates/base.html.twig:
{% extends 'rock/base.html.twig' %}
{% block rock_content %}{% endblock %}
First Use Case
Override the sidebar menu in templates/rock/sidebar.html.twig:
{% extends 'rock/_sidebar.html.twig' %}
{% block rock_sidebar_menu %}
{{ parent() }}
<li><a href="{{ path('app_home') }}">Custom Link</a></li>
{% endblock %}
Extending the Control Panel
templates/rock/:
base.html.twig (layout)sidebar.html.twig (navigation)user_menu.html.twig (top-right menu){% block rock_[feature] %} to inject content.Dynamic Menu Items Add items via Twig or controller:
{% block rock_sidebar_menu %}
{{ parent() }}
{% for item in app.rock.menu_items %}
<li><a href="{{ item.path }}">{{ item.label }}</a></li>
{% endfor %}
{% endblock %}
Stimulus Integration
Leverage built-in Stimulus controllers (e.g., rock-toggle) for interactive elements:
<div data-controller="rock-toggle" data-rock-toggle-target="menu">
<!-- Toggle logic -->
</div>
Responsive Design
Use rock-responsive classes (e.g., rock-responsive--mobile) for conditional styling.
make:auth for user management.assets/rock/ (processed via Webpack Encore).// src/Controller/RockController.php
public function menuItems(): array
{
return [
['path' => 'home', 'label' => 'Home'],
['path' => 'dashboard', 'label' => 'Dashboard'],
];
}
Twig Block Conflicts
{{ parent() }} to preserve default content.{% block rock_header %}
{{ parent() }} <!-- Renders default header -->
<div>Custom Header</div>
{% endblock %}
Stimulus Controller Naming
rock- (e.g., rock-custom) to avoid conflicts.Missing Documentation
Asset Pipeline
vendor/braunstetter/rock-bundle/resources/.config/packages/dev/twig.yaml:
twig:
debug: true
Custom User Menu
Override templates/rock/user_menu.html.twig and inject Symfony’s security context:
{% if app.user %}
<span>Welcome, {{ app.user.username }}</span>
{% endif %}
Dynamic Theming Use Twig globals to pass theme variables:
# config/packages/twig.yaml
twig:
globals:
rock_theme: 'dark'
Then in Twig:
{% if rock_theme == 'dark' %}
<link rel="stylesheet" href="{{ asset('css/rock-dark.css') }}">
{% endif %}
Localization
Extend translation files in translations/rock.en.yaml for menu labels or messages.
Event Listeners Hook into RockBundle events (if documented) or create custom events for extensibility.
How can I help you explore Laravel packages today?