[DMIG-6] Put Migrations under own namespace to avoid problems with Autoloader Created: 30/Jun/10  Updated: 16/Nov/11

Status: Open
Project: Doctrine Migrations
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Marcus Stöhr Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I think it would be a good idea to put the Migrations classes under their own namespace. If you use \Doctrine\Common\ClassLoader for loading both, DBAL and Migrations, you need to load Migrations before DBAL to avoid raising an exception.

Throws exception:

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(APPLICATION_PATH . '/../library/Doctrine/DBAL/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL\Migrations', realpath(APPLICATION_PATH . '/../library/Doctrine/Migrations/lib'));
$classLoader->register();

Works:

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL\Migrations', realpath(APPLICATION_PATH . '/../library/Doctrine/Migrations/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(APPLICATION_PATH . '/../library/Doctrine/DBAL/lib'));
$classLoader->register();


 Comments   
Comment by Jonathan H. Wage [ 30/Jun/10 ]

I am not sure we should do this. The migrations are an extension of the DBAL so it makes sense to be under that namespace. I thin it is normal to have to register the autoloaders in the right order, no?

Comment by Marcus Stöhr [ 01/Jul/10 ]

Yes, with the migrations being an extension of the DBAL I agree with you. As of today I wasn't aware of the fact that the autoloader using a stack (I should have checked that prior). However, it would be nice to have either some documentation about it or extend the ClassLoader to handle this implicit.

Comment by Jonathan H. Wage [ 01/Jul/10 ]

I will add some documentation about using multiple class loaders and order.

Generated at Tue Dec 23 01:41:22 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.