Php 基于Zend框架的条令Orm工具

Php 基于Zend框架的条令Orm工具,php,zend-framework,doctrine-orm,zend-framework2,Php,Zend Framework,Doctrine Orm,Zend Framework2,为了在Zend 2项目中使用Doctrine模块ORM工具,我需要通过Zend运行命令,以便正确建立index.php和application.config.php中定义的引导选项 这些定义的总和允许加载一个配置文件,其中包含我希望注入的DB设置。这是通过自定义DBALConnectionFactory实现的 my application.config.php中的条令配置如下: 'doctrine' => array( 'entity_path' => array (

为了在Zend 2项目中使用Doctrine模块ORM工具,我需要通过Zend运行命令,以便正确建立index.php和application.config.php中定义的引导选项

这些定义的总和允许加载一个配置文件,其中包含我希望注入的DB设置。这是通过自定义DBALConnectionFactory实现的

my application.config.php中的条令配置如下:

'doctrine' => array(
    'entity_path' => array (
        __DIR__ . '../src/Application/Entity'
    ),
    'driver' => array(
        'ApplicationDriver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(__DIR__ . '/../src/Application/Entity')
        ),
        'orm_default' => array(
            'drivers' => array(
                'Application\Entity' => 'ApplicationDriver'
            )
        )
    ),
    'connection' => array(
        'orm_default' => array(
            'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
            'DoctrineTypeMappings' => array(
                'enum' => "string"
            )
        )
    )
),
'doctrine_factories' => array(
    'connection' => 'Application\ORM\DBALConnectionFactory',
 ),
根据Sam的说法,我应该可以使用

php public/index.php orm:schema-tool:create
但我所做的只是列出可用的命令,这些命令表明参数没有正确映射

我还从项目根目录尝试了以下命令,但无效:

php public/index.php doctrine orm:schema-tool:create
php public/index.php doctrine orm orm:schema-tool:create

有人通过Zend使用条令工具吗?收到所有回复,非常感谢

该问题是由自定义控制台路由干扰标准路由的参数引起的。我修改了它,将通过public/index.php发出的所有请求直接传递到标准路由器

public function match(Request $request)
{
    // Get command line arguments and present working directory from
    // server superglobal:
    $filename = $request->getScriptName();

    if ("public/index.php" === $filename) {
        return parent::match($request);
    }

    // WARNING: cwd is $APPLICATION_HOME, so that throws off realpath!
    //
    // Convert base filename (minus .php extension and underscores) and
    // containing directory name into action and controller, respectively:
    $base = basename($filename, ".php");
    $actionName = str_replace('_', '', $base);

    $dir = dirname($filename);
    //invoked in directory e.g. $base=util/ping.php
    $level1 = basename(dirname($filename));
    // re-orient relative to APPLICATION_HOME
    $path   = $level1 . '/' . basename($filename);
    $controller = basename($dir);

    $routeMatch = new RouteMatch(
        array('controller' => $controller, 'action' => $actionName), 1
    );

    // Override standard routing:
    $routeMatch->setMatchedRouteName('default');
    return $routeMatch;
}