我有这个错误:
捆绑“AcmeOggyBundle”不存在或未启用。也许您忘了将它添加到AppKernel.php文件的registerBundles()方法中?
以下是registerBundles
文件中的AppKernel.php
功能:
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Acme\OggyBundle\OggyBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
我不明白......我包含了包new Acme\OggyBundle\OggyBundle()
,但收到错误,说我的包不包括在内!为什么呢?
日志文件:
[2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\ChromePhpHandler::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\Fragment\FragmentHandler::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse". [] [] [2013-06-13 10:46:20] event.DEBUG: Notified event "kernel.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onKernelTerminate". [] []
答案 0 :(得分:1)
如果您的软件包的名称是 Acme OggyBundle ...那么您需要注册...
// ...
new Acme\OggyBundle\AcmeOggyBundle(),
// ...
...而不是
new Acme\OggyBundle\OggyBundle(),
AcmeOggyBundle类必须在文件中......
src/Acme/OggyBundle/AcmeOggyBundle.php
...使用名称空间 Acme \ OggyBundle 和类名 AcmeOggyBundle
<?php
namespace Acme\OggyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeOggyBundle extends Bundle
{
}
如果您的捆绑包仍未加载...请确保 src / 文件夹中的类自动加载。
你的composer.json必须包含
"autoload": {
"psr-0": { "": "src/" }
}
然后跑......
composer update -o
...为了重新生成由作曲家生成的 vendor / autoload.php 。