我试图整合Doctrine2和ZF2。我可以成功创建一个Doctrine Entity,然后将它同步到我的数据库,以便创建表格,但是当我进入网页时,会出现:
在页面顶部看到那些奇怪的字符,是的,我的实体的文件名是UauthEntity.php
我的配置文件是:
ZendProject /配置/自动加载/ 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 /配置/ 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。
我会对此问题表示感谢。
答案 0 :(得分:1)
在某个地方你有一个v var_dump
或任何打印它的东西。 ZF2或Doctrine中没有可以打印这样的信息的功能,所以它必须来自某个地方。尝试禁用UAth
模块(以确保转储在模块内),然后在此模块中检查页面页面以查看问题隐藏的位置。