生产模式下的Symfony2;由于FOSUserBundle而无法工作


Symfony2 in production mode doesn't work because of FOSUserBundle

我正试图将我的大学symfony2项目部署到我的生产服务器上。在开发模式下,一切正常。

因此,我通过git将项目从服务器克隆到宿主。parameters.yml配置良好,composer是最新的,fixture也已加载到数据库中。

当我通过http调用web文件夹时,symfony2显示一个空白页面。prod.log简而言之显示了以下内容:

[2015-11-12 21:16:41] request.CRITICAL: Exception thrown when handling an exception (Doctrine'Common'Persistence'Mapping'MappingException: Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS'UserBundle'Entity'User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 86) {"exception":"[object] (Doctrine''Common''Persistence''Mapping''MappingException(code: 0): Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS''UserBundle''Entity''User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:86)"} []
[2015-11-12 21:16:41] php.CRITICAL: Uncaught Exception: Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS'UserBundle'Entity'User'. {"type":1,"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php","line":86,"level":6143,"stack":[{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php","line":117,"function":"invalidMappingFile","class":"Doctrine''Common''Persistence''Mapping''MappingException","type":"::","args":["FOS''UserBundle''Entity''User","FOS.UserBundle.Entity.User.orm.xml"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php","line":58,"function":"getElement","class":"Doctrine''Common''Persistence''Mapping''Driver''FileDriver","type":"->","args":["FOS''UserBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php","line":102,"function":"loadMetadataForClass","class":"Doctrine''ORM''Mapping''Driver''XmlDriver","type":"->","args":["FOS''UserBundle''Entity''User","[object] (Doctrine''ORM''Mapping''ClassMetadata: Doctrine''ORM''Mapping''ClassMetadataInfo@00000000558022090000000071882094)"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php","line":116,"function":"loadMetadataForClass","class":"Doctrine''Common''Persistence''Mapping''Driver''MappingDriverChain","type":"->","args":["FOS''UserBundle''Entity''User","[object] (Doctrine''ORM''Mapping''ClassMetadata: Doctrine''ORM''Mapping''ClassMetadataInfo@00000000558022090000000071882094)"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php","line":332,"function":"doLoadMetadata","class":"Doctrine''ORM''Mapping''ClassMetadataFactory","type":"->","args":["[object] (Doctrine''ORM''Mapping''ClassMetadata: Doctrine''ORM''Mapping''ClassMetadataInfo@00000000558022090000000071882094)",null,false,[]]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php","line":216,"function":"loadMetadata","class":"Doctrine''Common''Persistence''Mapping''AbstractClassMetadataFactory","type":"->","args":["Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php","line":265,"function":"getMetadataFor","class":"Doctrine''Common''Persistence''Mapping''AbstractClassMetadataFactory","type":"->","args":["Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php","line":67,"function":"getClassMetadata","class":"Doctrine''ORM''EntityManager","type":"->","args":["Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php","line":50,"function":"createRepository","class":"Doctrine''ORM''Repository''DefaultRepositoryFactory","type":"->","args":["[object] (Doctrine''ORM''EntityManager: {})","Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php","line":665,"function":"getRepository","class":"Doctrine''ORM''Repository''DefaultRepositoryFactory","type":"->","args":["[object] (Doctrine''ORM''EntityManager: {})","Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Doctrine/UserManager.php","line":40,"function":"getRepository","class":"Doctrine''ORM''EntityManager","type":"->","args":["Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":835,"function":"__construct","class":"FOS''UserBundle''Doctrine''UserManager","type":"->","args":["[object] (Symfony''Component''Security''Core''Encoder''EncoderFactory: {})","[object] (FOS''UserBundle''Util''Canonicalizer: {})","[object] (FOS''UserBundle''Util''Canonicalizer: {})","[object] (Doctrine''ORM''EntityManager: {})","Hsd''Bundle''ClickerBackendBundle''Entity''User"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getFosUser_UserManagerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1635,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["fos_user.user_manager"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getFosUser_UserProvider_UsernameService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1653,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["fos_user.user_provider.username"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getSecurity_Authentication_ManagerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1151,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["security.authentication.manager"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getSecurity_AuthorizationCheckerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1524,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["security.authorization_checker",2]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getTwigService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1550,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["twig"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getTwig_Controller_ExceptionService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2934,"function":"get","class":"Symfony''Component''DependencyInjection''Container","type":"->","args":["twig.controller.exception"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2559,"function":"createController","class":"Symfony''Bundle''FrameworkBundle''Controller''ControllerResolver","type":"->","args":["twig.controller.exception:showAction"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3102,"function":"getController","class":"Symfony''Component''HttpKernel''Controller''ControllerResolver","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3071,"function":"handleRaw","class":"Symfony''Component''HttpKernel''HttpKernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",2]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3222,"function":"handle","class":"Symfony''Component''HttpKernel''HttpKernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",2,false]},{"file":"/var/www/virtual/username/symfonyproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php","line":50,"function":"handle","class":"Symfony''Component''HttpKernel''DependencyInjection''ContainerAwareHttpKernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",2,false]},{"function":"onKernelException","class":"Symfony''Component''HttpKernel''EventListener''ExceptionListener","type":"->","args":["[object] (Symfony''Component''HttpKernel''Event''GetResponseForExceptionEvent: {})","kernel.exception","[object] (Symfony''Component''EventDispatcher''ContainerAwareEventDispatcher: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2272,"function":"call_user_func","args":[["[object] (Symfony''Component''HttpKernel''EventListener''ExceptionListener: {})","onKernelException"],"[object] (Symfony''Component''HttpKernel''Event''GetResponseForExceptionEvent: {})","kernel.exception","[object] (Symfony''Component''EventDispatcher''ContainerAwareEventDispatcher: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2201,"function":"doDispatch","class":"Symfony''Component''EventDispatcher''EventDispatcher","type":"->","args":[[["[object] (JMS''I18nRoutingBundle''EventListener''LocaleChoosingListener: {})","onKernelException"],["[object] (Symfony''Component''HttpKernel''EventListener''ExceptionListener: {})","onKernelException"]],"kernel.exception","[object] (Symfony''Component''HttpKernel''Event''GetResponseForExceptionEvent: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3141,"function":"dispatch","class":"Symfony''Component''EventDispatcher''EventDispatcher","type":"->","args":["kernel.exception","[object] (Symfony''Component''HttpKernel''Event''GetResponseForExceptionEvent: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3077,"function":"handleException","class":"Symfony''Component''HttpKernel''HttpKernel","type":"->","args":["[object] (Doctrine''Common''Persistence''Mapping''MappingException(code: 0): Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS''UserBundle''Entity''User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:86)","[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",1]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3222,"function":"handle","class":"Symfony''Component''HttpKernel''HttpKernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",1,true]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2444,"function":"handle","class":"Symfony''Component''HttpKernel''DependencyInjection''ContainerAwareHttpKernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)",1,true]},{"file":"/var/www/virtual/username/symfonyproject/web/app.php","line":28,"function":"handle","class":"Symfony''Component''HttpKernel''Kernel","type":"->","args":["[object] (Symfony''Component''HttpFoundation''Request: GET /de/ HTTP/1.1'r'nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'r'nAccept-Encoding:   gzip, deflate'r'nAccept-Language:   de,en-US;q=0.7,en;q=0.3'r'nAuthorization:     'r'nCache-Control:     max-age=0'r'nConnection:        close'r'nCookie:            hl=de'r'nHost:              dev.mywebsite.de'r'nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0'r'nX-Forwarded-For:   91.136.154.136'r'nX-Forwarded-Port:  80'r'nX-Forwarded-Proto: http'r'nX-Php-Ob-Level:    1'r'n'r'n)"]}]} []

我试着做了什么?

  • 删除app/cache/*
  • 删除vendor/*并重新运行composer update

服务器(dev和prod)都运行PHP 5.6.2

有人能告诉我出了什么问题吗?

;解决方案":

libxml_disable_entity_loader(false);添加到web文件夹中的app.php


在github问题上找到了解决方法。