I an trying to include a file into the Symfony 4 routes, and can’t figure out what would be the correct way to put in the Bundle name. My routes.yml:
icatcher_builder: # loads routes from the given routing file stored in some bundle resource: '@ICatcher/Builder/Resources/config/routes.yaml'
My bundles.php:
AppICatcherBuilderBuilder::class => ['dev' => true, 'test' => true],
And I get this error:
An exception has been thrown during the rendering of a template (“Bundle “ICatcher” does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in @ICatcher/Builder/Resources/config/routes.yaml (which is being imported from “[PATH]config/routes.yaml”). Make sure the “ICatcher/Builder/Resources/config/routes.yaml” bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path “@ICatcher/Builder/Resources/config/routes.yaml” is not empty.”).
If I just copy the routes into the main route.yml file instead of including an external resource – all works fine.
Advertisement
Answer
Symfony has strict rules of naming Bundle classes, which I found out here in the documentation: https://symfony.com/doc/current/bundles/best_practices.html
So my Bundle class is now re-named from AppICatcherBuilderBuilder
to AppICatcherBuilderICatcherBuilder
and the file is re-named the same way ICatcherBuilder.php
and it works.