Aay*_*ush 5 registry bundle symfony
我用app/console创建了一个新的包.试图打印一个简单的问候,所以我可以继续前进.我自动加载了命名空间,注册了bundle,创建了一个页面,但Symfony检测到异常:
Bundle "PageBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your AppKernel.php file?
Run Code Online (Sandbox Code Playgroud)
但我已经这样做了.
日志显示:
[2011-06-08 23:41:56] request.CRITICAL: InvalidArgumentException: Bundle "PageBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your AppKernel.php file? (uncaught exception) at /Applications/MAMP/htdocs/Symfony/app/bootstrap.php.cache line 634
Run Code Online (Sandbox Code Playgroud)
我还清除了缓存的dev文件夹.任何人都可以帮我弄清楚什么是错的.我以前做过这个,这是我第一次遇到这个问题.与bootstrap.php.cache有关
谢谢!感谢所有的帮助.
码:
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\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Webmuch\PageBundle\WebmuchPageBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Symfony\Bundle\WebConfiguratorBundle\SymfonyWebConfiguratorBundle();
}
return $bundles;
}
Run Code Online (Sandbox Code Playgroud)
捆绑包还在分析器中显示为活动捆绑包.
它看起来不像引导缓存的问题(第634行指向该Kernel::getBundles()方法,这就是抛出异常),但为了以防万一,有一个脚本可以重建它:bin\build_bootstrap.php.缓存的存在是为了减少require()Symfony加载核心Symfony类所需的数量,只要您使用其中一个beta,就不太可能存在任何实际错误.
听起来这可能是一个命名问题:你的错误抱怨缺少PageBundle,但根据你的内核,bundle应该被称为WebmuchPageBundle.你有没有正确引用它routing_dev.yml?路由配置示例如下:
page:
resource: "@WebmuchPageBundle/Controller/DefaultController.php"
type: annotation
Run Code Online (Sandbox Code Playgroud)
因为您只为开发和测试环境定义了该包,所以您应该使用routing_dev.yml和不使用routing.yml.
接下来,检查bundle类是否正确命名.您应该在捆绑包的根目录中有一个文件(例如src/Webmuch/PageBundle/WebmuchPageBundle.php),其中包含以下内容:
namespace Webmuch\PageBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class WebmuchPageBundle extends Bundle
{
}
Run Code Online (Sandbox Code Playgroud)
哦,显然检查Web服务器的用户是否可以读取您的bundle目录.我认为会引发不同的错误,但值得检查!
| 归档时间: |
|
| 查看次数: |
15533 次 |
| 最近记录: |