Symfony生产环境抛出500错误:Doctrine\ORM\ORMException'未知实体命名空间别名'DSBlogBundle' [英] Symfony production environment throws 500 error: Doctrine\ORM\ORMException 'Unknown Entity namespace alias 'DSBlogBundle'
问题描述
我已经清除缓存,我访问了 http:// symfony。 dev / 我在本地运行该页面仍然完全为空,此错误在日志中:
致命错误:未捕获异常'Doctrine\ORM\ORMException '消息'Unknown Entity namespace alias'DSBlogBundle'。'
in /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:236
堆栈跟踪:
#0 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php(194):Doctrine\ORM\ORMException :: unknownEntityNamespace('DSBlogBundle')
#1 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(554):Doctrine\ORM\Configuration-> getEntityNamespace('DSBlogBundle ')
#2 /Applications/MAMP/htdocs/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(194):Doctrine\ORM\Mapping\ClassMetadataFactory - > getFqcnFromAlias('DSBlogBundle','Blog')
#3 /应用程序/ MAMP / htdocs / symfony / vendor / doctrine / orm / lib / Doctrine / ORM / EntityManager.php(295):Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-> getMetadataFor('DSBlogBundle: ..')
#4 /应用程序/ MAMP / htdocs / symfony /供应商在/Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php第236行
我没有得到的是'Unknown Entity namespace alias'DSBlogBundle'
在开发环境中完全已知。有人知道我失踪了吗?任何帮助深表感谢!谢谢!
几种可能性我可以想到:
1)如果您的代码在开发环境中正常运行,那么可能是缓存问题和/或权限问题。确保您的文件与您的Web服务器相关联的用户/进程可读,并确保该用户可以写入 prod
缓存目录,以便生成必要的文件。我通常做的是运行清除缓存控制台命令作为该用户以避免意外的缓存问题,像这样(在linux上):
sudo -u www-user php app / console cache:clear --env = prod
如果你在linux上进行开发,您必须以root用户或具有管理员权限的其他用户身份登录,才能以除您自己以外的用户运行命令。
2)您可以在 prod
环境中定义的配置在 prod
环境中不存在。仔细检查您的 app / config
文件夹中的文件。我的第一个猜测是, DSBlogBundle
在 app / AppKernel.php
中没有正确定义,但我相信环境独立,所以它不能在开发工作,但不能生产。
I'm learning Symfony2, really cool stuff. But I do run into some trouble when I want to try and visit the production environment. I have followed the Symblog Tutorial that is located here: http://tutorial.symblog.co.uk/
I have cleared the cache and I visit http://symfony.dev/ I have running locally. The page remains totally blank and this error is in the log:
Fatal error: Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unknown Entity namespace alias 'DSBlogBundle'.'
in /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:236
Stack trace:
#0 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php(194): Doctrine\ORM\ORMException::unknownEntityNamespace('DSBlogBundle')
#1 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(554): Doctrine\ORM\Configuration->getEntityNamespace('DSBlogBundle')
#2 /Applications/MAMP/htdocs/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(194): Doctrine\ORM\Mapping\ClassMetadataFactory->getFqcnFromAlias('DSBlogBundle', 'Blog')
#3 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(295): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('DSBlogBundle:Bl...')
#4 /Applications/MAMP/htdocs/symfony/vendor in /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php on line 236
What I don't get is that the 'Unknown Entity namespace alias 'DSBlogBundle'
is perfectly "known" in the development environment. Does anyone know what I am missing? Any help is much appreciated! Thank you!
Couple possibilities I can think of:
1) If your code functions properly in the development environment, then it could be a cache problem and/or a permissions problem. Make sure your files are readable by the user/process associated with your web server and make sure the prod
cache directory is writable by that user so it can generate the necessary files. What I generally do is run the clear cache console command AS that user to avoid unexpected cache problems, like this (on linux):
sudo -u www-user php app/console cache:clear --env=prod
If you're developing on linux, you must be logged in as either root or another user with administrator privileges to run a command as a user other than yourself.
2) You may have configurations defined in the dev
environment that don't exist in the prod
environment. Double check the files in your app/config
folder. My first guess would have been that the DSBlogBundle
wasn't correctly defined in app/AppKernel.php
but I believe that's environment independent so it couldn't work in dev but not prod.
这篇关于Symfony生产环境抛出500错误:Doctrine\ORM\ORMException'未知实体命名空间别名'DSBlogBundle'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!