gpt4 book ai didi

php - Symfony - DoctrineBundle 未在您的应用程序中注册

转载 作者:行者123 更新时间:2023-12-03 15:13:29 25 4
gpt4 key购买 nike

我对 Doctrine Bundle 有疑问。当我尝试进入网页时出现错误:

The DoctrineBundle is not registered in your application.

这很奇怪,因为在 config/bundles.php 中我有:

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
];

如何添加可供应用使用的 Doctrine Bundle?或者也许是有 Doctrine/规则的东西?感谢您的帮助。

编辑

当我在 Controller 中转储 $this 时,在 services.kernel.bundles 中我有:

["DoctrineBundle"]=>
object(Doctrine\Bundle\DoctrineBundle\DoctrineBundle)#73 (6) {
["autoloader":"Doctrine\Bundle\DoctrineBundle\DoctrineBundle":private]=>
NULL
["name":protected]=>
string(14) "DoctrineBundle"
["extension":protected]=>
NULL
["path":protected]=>
NULL
["namespace":"Symfony\Component\HttpKernel\Bundle\Bundle":private]=>
string(30) "Doctrine\Bundle\DoctrineBundle"
["container":protected]=>
*RECURSION*
}
}

最佳答案

试试这个;将此行添加到 app/AppKernel.php 文件中。

新的 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),

文件看起来像。

class AppKernel extends Kernel
{
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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new DashboardBundle\DashboardBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
);

if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}

return $bundles;
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}

关于php - Symfony - DoctrineBundle 未在您的应用程序中注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47387759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com