How do I fix "Add myBundle to the asseticBundle config" symfony2 exception?
Yes I tried and it solved the issue for me. For someone (like me) who doesn't know initially how to add then just:
- edit
app/config/config.yml
- then go to
assetic:
- under assetic: go to
bundles: []
- and in
bundles: []
//type your bundle name
for instance if your bundle is Acme\DemoBundle
, then do the following
assetic: bundles: [ AcmeDemoBundle ]
No quotes around AcmeDemoBundle
. That's it. (Symfony2)
Sometimes you need to make decisions on the fly, then you can use use DependencyInjection.
For example to loads and manages configuration:
<?phpnamespace You\ExampeBundle\DependencyInjection;use Symfony\Component\DependencyInjection\ContainerBuilder;/* ... */class YouExampeExtension extends Extension{ /* ... */ public function load(array $configs, ContainerBuilder $container) { /* ... */ $aAsseticBundle = $container->getParameter('assetic.bundles'); $aAsseticBundle[] = 'YouExampeBundle'; $aAsseticBundle[] = 'AnotheBundle'; $container->setParameter('assetic.bundles', $aAsseticBundle); /* ... */ }}
You can use more complex logic to manipulate the configuration(in reasonable limits)