How to install or integrate bundles in Symfony2

后端 未结 2 1652
执念已碎
执念已碎 2020-12-20 08:00

i have downloaded a sonata admin bundle, and have placed in /var/www/Symfony/vendor/symfony/src/Symfony/Bundle, and have made an entry in AppKernel.php

相关标签:
2条回答
  • 2020-12-20 08:31

    You need to move the bundle to

    /var/www/Symfony/vendor/bundles
    

    Then in AppKernel.php add

    new Sonata\AdminBundle\SonataAdminBundle(),
    

    in your $bundles array.

    In autoload.php add

    'Sonata'           => __DIR__.'/../vendor/bundles',
    

    to the $loader->registerNamespaces array

    0 讨论(0)
  • 2020-12-20 08:35

    First off, SonataAdminBundle lives in Sonata namespace, not Symfony. So you'll have to rewrite the instantiation in app/AppKernel.php to:

    new Sonata\AdminBundle\SonataAdminBundle()
    

    You also have to register namespace in app/autoload.php:

    $loader->registerNamespaces(array(
    ...
    'Sonata' => __DIR__.'/path/to/parent/of/Sonata/folder'
    ...
    ));
    
    0 讨论(0)
提交回复
热议问题