我正在尝试整合 Doctrine2 和 ZF2。我可以成功创建一个 Doctrine 实体,然后将其同步到我的数据库,以便创建表,但是当我转到网页时,会出现:
在页面顶部看到那些奇怪的字符,是的,我的实体的文件名是 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 中。
我会很感激这个问题的一些帮助。