2

我的 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 [] []

我在谷歌搜索了错误,发现了这两个主题:

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
4

1 回答 1

0

在第一次使用 Capifony 进行部署时,曾经遇到过类似的问题。我只能通过手动清除 app/cache/prod 文件夹来解决它。不使用缓存:清除,但实际上删除了文件夹,

rm -rf app/cache/prod

我还没有弄清楚为什么cache:clear --env=prod有时无法正确清除它,这可能是权限问题。

于 2012-05-16T11:49:48.240 回答