Jira issue originally created by user nicokaiser:
The ClassLoader seems to ignore classNames that start with "\".
When it is instantiated in tools/sandbox/doctrine.php with a parameter instead of for the global namespace, it does not find "\Doctrine\Common\Cli\Tasks\HelpTask" (but finds all classes that start with "Doctrine"). To reproduce, change this line in tools/sandbox/doctrine.php
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
The script fails now:
PHP Fatal error: Class '\Doctrine\Common\Cli\Tasks\HelpTask' not found in /home/kaiser/doctrine/doctrine/lib/Doctrine/Common/Cli/TaskNamespace.php on line 81
Registering the ClassLoader only for some specific namespaces (e.g. "Doctrine", "Entities", "Proxies") is vital for inclusion in an existing Zend autoloading environment...
Comment created by nicokaiser:
... or will the "IsolatedClassLoader" be the one to use for such environments?
The same happens when I change doctrine.php to use the IsolatedClassLoader:
require*once __DIR_* . '/../../lib/Doctrine/Common/IsolatedClassLoader.php';
$classLoader = new \Doctrine\Common\IsolatedClassLoader('Doctrine');
$classLoader->setBasePath(*_DIR_* . '/../../lib');
// Variable $configuration is defined inside cli-config.php
require*once __DIR_* . '/cli-config.php';
$cli = new \Doctrine\Common\Cli\CliController($configuration);
Comment created by romanb:
This sounds like it was caused by the recent CLI refactorings.
A class name passed to a class loader should never start with a backslash, class names in strings are always fully-qualified, hence the leading backslash is senseless.
So I am curious as to where/why the class loader gets "\Doctrine\Common\Cli\Tasks\HelpTask" instead of "Doctrine\Common\Cli\Tasks\HelpTask".
I'm sure this is caused by the new CLI code.
This should be fixed now. However, the CLI does still not work well. Just tested "doctrine orm:schema-tool --create" and it quits with a "Fatal error: Call to undefined method Doctrine\ORM\Tools\Cli\Tasks\SchemaToolTask::getEntityManager() in /Users/robo/dev/php/Doctrine/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php on line 144"
Ok, this is now fixed, too. Guilherme is working on some improvements.
The CLI should work now but it does currently not recognize the $globalArguments. Thats why you will probably need to specify the --class-dir on the CLI manually currently.
I'll mark this one as resolved and open a new issue for Guilherme concerning the global CLI arguments.
If this issue is not fixed for you feel free to reopen.
Issue was closed with resolution "Fixed"