Zend Framework 2 如何设置 Doctrine 2 代理目录

2022-01-03 00:00:00 php doctrine-orm zend-framework2

所以我在 Zend Framework 2 中使用 Doctrine 2 模块,根据 Jason Grimes 的 turorial (http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/).

So I am using Doctrine 2 module in Zend Framework 2 configured according to Jason Grimes' turorial (http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/).

有时我会不断收到此错误:

Sometimes I keep getting this error though:

您的代理目录必须是可写的.

Your proxy directory must be writable.

如何设置代理目录?

这是我在 module.config.php 中的 Doctrine 配置:

Here is my Doctrine configuration from module.config.php:

'doctrine' => array(
    'driver' => array(
        __NAMESPACE__ . '_driver' => array(
            'class' => 'DoctrineORMMappingDriverAnnotationDriver',
            'cache' => 'array',
            'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
        ),
        'orm_default' => array(
            'drivers' => array(
                __NAMESPACE__ . 'Entity' => __NAMESPACE__ . '_driver'
            ),
        ),
    ),
),

推荐答案

默认代理目录为data/DoctrineORMModule/Proxy.我想你知道如何使它可写,对吗?

The default proxy directory is data/DoctrineORMModule/Proxy. I guess you know how to make it writable, right?

如果由于某种原因需要更改,可以覆盖相应的配置键:

If you need to change it for some reason, you can overwrite the appropriate configuration key:

<?php
return array(
    'doctrine' => array(
        'configuration' => array(
            '<YOUR DRIVER NAME (orm_default by default)>' => array(
                'proxy_dir' => 'data/DoctrineORMModule/Proxy',
                'proxy_namespace' => 'DoctrineORMModuleProxy',
            )    
        )
    )
);
?>

希望这会有所帮助.

相关文章