0

我正在尝试整合 Doctrine2 和 ZF2。我可以成功创建一个 Doctrine 实体,然后将其同步到我的数据库,以便创建表,但是当我转到网页时,会出现: ZF2怪异角色

在页面顶部看到那些奇怪的字符,是的,我的实体的文件名是 UauthEntity.php

我的配置文件是:

ZendProject/config/autoload/doctrine.local.php

<?php

$dbParams = array(
    'hostname' => 'localhost',
    'port' => 3306,
    'username' => 'root',
    'password' => 'root',
    'database' => 'project001'
);

return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'params' => array(
                    'host' => $dbParams['hostname'],
                    'port' => $dbParams['port'],
                    'user' => $dbParams['username'],
                    'password' => $dbParams['password'],
                    'dbname' => $dbParams['database'],
                    'driverOptions' => array(
                        \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
                    ),
                )
            )
        )
    )
);

ZendProject/config/application.config.php

<?php
return array(
    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'ZendDeveloperTools',
        'DoctrineModule',
        'DoctrineORMModule',
        'Application',
        'Uauth',
        'Album',
    ), //etc... (default in ZendSkeletonApplication)

ZendProject/module/Uauth/config/module.config.php(底部的学说配置)

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'Uauth\Controller\Uauth' => 'Uauth\Controller\UauthController',
        ),
    ),
    // The following section is new and should be added to your file
    'router' => array(
        'routes' => array(
            'uauth' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '/uauth[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Uauth\Controller\Uauth',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),

    'view_manager' => array(
        'template_path_stack' => array(
            'uauth' => __DIR__ . '/../view',
        ),
    ),
    'doctrine' => array(
        'driver' => array(
            'uauth_entities' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../src/Uauth/Model/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    'Model\Entity' => 'uauth_entities'
                )
            ))),
);

并且实体在 ZendProject/module/Uauth/src/Uauth/Model/Entity/UauthEntity.php 中。

我会很感激这个问题的一些帮助。

4

1 回答 1

1

某处你有 avvar_dump或任何打印这个的东西。ZF2 或 Doctrine 中没有任何功能可以打印这样的信息,因此它必须来自某个地方。尝试禁用UAth模块(以确保转储在模块内),然后检查此模块中的页面以查看问题隐藏的位置。

于 2014-07-04T06:35:37.693 回答