Search code examples
doctrine-ormzend-framework2zfdoctrine

ZF2 and Doctrine2 weird print


I'm trying to integrate Doctrine2 and ZF2. I can succesfully create a Doctrine Entity and then sync it to my database so the table is created but when I go to the webpage this appears: ZF2 weird characters

See those weird characters at the top of the page, and yes, the filename for my entity is UauthEntity.php

My configuration files are:

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 (doctrine configuration at bottom)

<?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'
                )
            ))),
);

and the entity is in ZendProject/module/Uauth/src/Uauth/Model/Entity/UauthEntity.php.

I'll appreciate some help with this problem.


Solution

  • Somewhere you have a vvar_dump or whatsoever which prints this. There is no feature in ZF2 or Doctrine which prints information like this, so it must come from somewhere. Try to disable the UAth module (to be certain that dump is inside the module) and then check page for page in this module to see where the problem hides.