- Does this package work with vanilla Laravel projects?
- No, this package is specifically designed for Sylius-based frameworks like Monofony/Skeleton. It relies on Sylius’s event system, which isn’t natively available in Laravel. For Laravel, consider alternatives like `spatie/laravel-menu` or custom Blade directives.
- How do I add a custom menu item to the Sylius admin dashboard?
- Create an event subscriber that listens to `sylius.menu.admin.main`. In the subscriber’s `onMenuBuild` method, modify the `$menu` array to inject your custom items. Ensure your subscriber is tagged as a service in your `services.yaml` or `config/packages`.
- What Laravel versions support this package?
- This package isn’t Laravel-native, but it can work in Laravel projects *if* you’re using Sylius (e.g., via `sylius/sylius` or `monofony/skeleton`). For pure Laravel, it’s incompatible. Check Symfony 6.x and PHP 8.0+ compatibility for your stack.
- Is there a way to dynamically populate menu items based on user roles?
- Yes, in your event subscriber, access the `Security` component or `TokenStorage` to check user roles. Modify the `$menu` array conditionally, like adding a `Reports` section only for admin users. Example: `if ($this->security->isGranted('ROLE_ADMIN')) { ... }`
- Will this package break if I update Sylius or Monofony?
- Potential risks exist if Sylius changes the `sylius.menu.admin.main` event structure or namespace. Test thoroughly after updates. If the event is deprecated, you may need to override the Twig template directly or use a fallback subscriber.
- Can I use this with Sylius 0.x or older versions?
- No, this package targets Sylius 1.x and Symfony 6.x. Older Sylius versions may use different event namespaces (e.g., `sylius.menu.main`). Check your Sylius version’s documentation for compatibility or use a custom Twig override as a fallback.
- How do I test if the menu extension is working?
- Clear Symfony’s cache (`php bin/console cache:clear`) and reload the Sylius admin dashboard. Verify your custom menu item appears. Use browser dev tools to inspect the rendered HTML or add debug logs in your subscriber’s `onMenuBuild` method.
- What if the event `sylius.menu.admin.main` doesn’t exist in my setup?
- This likely means your Sylius/Monofony version doesn’t support the event. As a fallback, manually extend the menu template in Twig by overriding `SyliusAdminBundle:Menu:main.html.twig` and adding your items in the `menu_items` block.
- Are there alternatives for Laravel projects without Sylius?
- For Laravel, consider `spatie/laravel-menu` for dynamic Blade-based menus or `orchid/platform` for admin panel integrations. If you need Sylius-like functionality, evaluate `sylius/sylius` or `monofony/skeleton` as a foundation before using this package.
- Does this package handle menu permissions or routing automatically?
- No, this package only injects menu items into the existing Sylius admin menu. You must manually define routes (e.g., in `routes.yaml`) and handle permissions (e.g., via Symfony’s voter system or Sylius’s guard system) separately.