Menu & Sidebar

The sidebar is driven entirely by the menu array in config/packages/admin_lte.yaml. The bundle resolves routes to URLs, computes the active state for the current request, and optionally hides items behind a security permission.

A real menu example

admin_lte:
    menu:
        - { label: 'Dashboard', route: 'app_dashboard', icon: 'bi bi-speedometer2' }

        - { header: 'MANAGEMENT' }

        - label: 'Users'
          icon: 'bi bi-people'
          permission: 'ROLE_ADMIN'      # hidden unless granted
          children:
              - { label: 'All users', route: 'app_user_index' }
              - { label: 'Create', route: 'app_user_new', badge: 'new', badge_class: 'text-bg-success' }

        - { label: 'Reports', route: 'app_report', route_params: { type: 'sales' }, icon: 'bi bi-graph-up' }

        - { label: 'Documentation', url: 'https://adminlte.io', icon: 'bi bi-book', target: '_blank' }

Item keys

KeyPurpose
labelThe visible text of the item.
headerRenders a non-clickable section header instead of a link.
routeA Symfony route name; resolved to a URL via the router.
route_paramsParameters passed when generating the route URL.
urlA literal URL; use instead of route for external links.
targetLink target, e.g. _blank for external links.
iconAn icon class, e.g. bi bi-people (Bootstrap Icons).
badgeA small badge label shown after the item.
badge_classBadge styling; defaults to text-bg-secondary.
permissionA role/attribute checked via the authorization checker.
childrenA nested array of items, rendered as a collapsible treeview.

Active-state behavior

The menu builder marks items active automatically based on the current request path:

  • A leaf item is active when its resolved URL matches the current path exactly.
  • It is also active when the current path is a sub-path of the item's URL (so ancestors highlight) — but / never matches everything.
  • A branch (an item with children) is active when any descendant is active, opening the treeview.
  • Items with no URL, an empty URL, or # are never marked active.

Security: the permission filter

When an item has a permission key, it is only rendered if the current user is granted that attribute. This requires symfony/security-bundle:

composer require symfony/security-bundle

If the security bundle is not installed, items with a permission are always shown. If there is no authentication token yet for the current path (for example, the firewall does not cover it), the item is hidden rather than throwing.

How it renders

Under the hood, AdminLteExtension exposes an adminlte_menu() Twig function that returns the resolved MenuItem tree, which <twig:Adminlte:Sidebar> renders recursively via <twig:Adminlte:SidebarNavItem>. The same tree feeds the ⌘K command palette, so every navigable menu entry is searchable for free.


AdminLTE 4 · Symfony port Edit on GitHub