【发布时间】:2012-05-06 04:38:42
【问题描述】:
我的 symfony2 项目在开发环境中完美运行。当我切换到生产环境时出现问题。当我调用具有实体数组的控制器并使用 JSMserializer 将其序列化为 json 时,它会崩溃。客户端仍然收到响应,但 json 为空,甚至没有“[]”。当我查看日志时,我可以看到这些错误:
security.INFO: Populated SecurityContext with an anonymous Token [] []
request.INFO: Matched route "employe_index" (parameters: "_controller": "Pisteur\WebRefugeManager\Bundle\CoreBundle\Controller\EmployeController::indexAction", "_route": "employe_index") [] []
request.CRITICAL: Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@proxy" in method Doctrine\MongoDB\Cursor::current() was never imported. Did you maybe forget to add a "use" statement for this annotation? (uncaught exception) at /home/wpdemo/symfony/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationException.php line 52 [] []
我在google中搜索了错误,发现了这两个主题:
https://github.com/doctrine/mongodb-odm/issues/255 https://github.com/schmittjoh/JMSSerializerBundle/issues/51
这些主题对我没有帮助,我真的不明白这个问题。有人有想法吗?
[编辑] 这是我的配置:
开发者:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: true
产品:
imports:
- { resource: config.yml }
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
[编辑]
这是我运行的命令:
php app/console cache:clear --env=prod --no-debug
php app/console cache:warmup
php app/console assets:install web
php app/console assetic:dump web --env=prod --no-debug
【问题讨论】:
-
这两个环境之间有什么配置差异?您是否启用了特定的元数据缓存驱动程序?
-
你试过清除你的应用程序/缓存吗?
-
在我看来是 php 会话问题,而不是 symfony 问题。您确定每个环境中的会话设置都相同吗?