How to install or integrate bundles in Symfony2
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
as $bundles = array( ... new Symfony\Bundle\SonataAdminBundle\SonataAdminBundle(),)
, but throwing an error as
Fatal error: Class 'Symfony\Bundle\SonataA开发者_如何学编程dminBundle\SonataAdminBundle' not found in /var/www/Symfony/app/AppKernel.php on line 21 Call Stack: 0.0001 326332 1. {main}() /var/www/Symfony/web/app_dev.php:0 0.0122 1121592 2. Symfony\Component\HttpKernel\Kernel->handle()
please help me as i am very new to symfony 2. As a whole please give a link or detail like how to install/configure any bundle that is downloaded. Thanks Ravi.M
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
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'
...
));
精彩评论