Installation:
composer require avanzu/admin-theme-bundle
For Symfony 2.8+, ensure Assetic is installed:
composer require symfony/assetic-bundle
Enable the Bundle:
Add to config/bundles.php (Symfony 4+) or app/AppKernel.php (Symfony 2/3):
new Avanzu\AdminThemeBundle\AvanzuAdminThemeBundle(),
Initialize Assets:
php bin/console assets:install --symlink
php bin/console avanzu:admin:initialize
php bin/console avanzu:admin:fetch-vendor
First Use Case: Extend the base layout in your controller:
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class DashboardController extends Controller
{
/**
* @Template("@AvanzuAdminTheme/Layout/base.html.twig")
*/
public function indexAction()
{
return [];
}
}
Base Layout: Extend @AvanzuAdminTheme/Layout/base.html.twig in your templates.
{% extends '@AvanzuAdminTheme/Layout/base.html.twig' %}
{% block body %}
<!-- Your content here -->
{% endblock %}
Custom Blocks: Override blocks like avanzu_body_start, sidebar, or navbar:
{% block sidebar %}
{{ parent() }}
<li class="treeview">
<a href="#"><i class="fa fa-dashboard"></i> <span>Dashboard</span></a>
</li>
{% endblock %}
config/packages/twig.yaml:
twig:
globals:
admin_skin: "skin-blue-light" # Default: skin-blue
Or via parameters.yml:
admin_skin: "%env(ADMIN_SKIN)%"
php bin/console avanzu:admin:rebuild
# config/packages/avanzu_admin_theme.yaml
avanzu_admin_theme:
use_assetic: false
{{ render(controller('AvanzuAdminThemeBundle:Navbar:notifications')) }}
avanzu.admin.theme.layout.render).{{ knp_menu_render('main_menu', {
'rootName': 'Dashboard',
'depth': 2,
'template': '@AvanzuAdminTheme/Sidebar/menu.html.twig'
}) }}
# config/packages/avanzu_admin_theme.yaml
avanzu_admin_theme:
menu:
main_menu: "main_menu" # KnpMenu alias
{% form_theme form '@AvanzuAdminTheme/Form/fields.html.twig' %}
templates/avanzu_admin_theme/form/fields.html.twig.{% extends '@AvanzuAdminTheme/Login/login.html.twig' %}
Asset Paths:
Resources/public/static/ may break if not symlinked.--symlink with assets:install.Assetic Conflicts:
avanzu_admin_theme:
use_assetic: false
Skin Overrides:
admin_skin) override per-page settings.{% set skin = app.global.admin_skin %}
Bower Dependencies:
ionicons@2.0.1) to avoid breakages.composer.json if needed.Windows Compatibility:
avanzu:admin:initialize may fail on Windows. Use WSL or manually copy assets.KnpMenu Integration:
knp_menu:
twig:
template: '@AvanzuAdminTheme/Sidebar/menu.html.twig'
Clear Cache:
php bin/console cache:clear
php bin/console assets:clear
Check Asset Compilation:
public/bundles/avanzuadmintheme/ exists after fetch-vendor.avanzu:admin:rebuild in dev mode.Twig Errors:
twig:
debug: true
avanzu_body_start).Event Dispatching:
avanzu.admin.theme.layout.render to modify the base layout:
$eventDispatcher->addListener('avanzu.admin.theme.layout.render', function (Event $event) {
$event->setArgument('custom_var', 'value');
});
Custom Templates:
templates/avanzu_admin_theme/ (e.g., base.html.twig).New Components:
Resources/views/Macros/.Configuration:
config/packages/avanzu_admin_theme.yaml:
avanzu_admin_theme:
layout:
title: "My App"
logo: "/path/to/logo.png"
navbar:
user_menu: false # Disable user dropdown
Translations:
translations/messages.en.yaml:
navbar:
notifications: "Notifications (%count%)"
{% block stylesheets %}
{{ parent() }}
{{ encore_entry_link_tags('admin') }}
{% endblock %}
php bin/console assets:install --no-debug
composer.json to auto-fetch vendors:
"scripts": {
"post-install-cmd": ["Avanzu\\AdminThemeBundle\\Composer\\ScriptHandler::fetchThemeVendors"],
"post-update-cmd": ["Avanzu\\AdminThemeBundle\\Composer\\ScriptHandler::fetchThemeVendors"]
}
How can I help you explore Laravel packages today?