pjmuller
pjmuller

Reputation: 79

Doctrine 2.0: get classloader to work for entities

I've been struggling quite some time to get my entities loaded in my first Doctrine 2.0 project. Everything works fine (got the other classes to load, connection with database trough DBAL is successful) except for loading my entity classes.

I'll give you the information you need.

Please help me on this one Thanks, Pj

Upvotes: 0

Views: 1364

Answers (1)

gilchris
gilchris

Reputation: 1241

First, \Doctrine\Common\ClassLoader find classes in 'includePath/namespace/' directory.

<?php
$sRoot = "/home/..../public_html/doctrinetest";
$classLoader = new \Doctrine\Common\ClassLoader('doctrinetest\entities', $sRoot.'/doctrinetest/entities');
$classLoader->register();
?>

The above code try to find class in '/home/..../public_html/doctrinetest/doctrinetest/entities/doctrinetest/entities/' directory. Of course, cannot found classes.

Second, getClassMetadata function of EntityManager want className including namespace for an argument.

Therefore use like this.

$em->getClassMetadata('\\doctrinetest\\entities\\Video');

Upvotes: 1

Related Questions