DDC-989: doctrine Cli not working under Zend Framework #1234

Closed
opened 2026-01-22 13:06:48 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 16, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user riplexus:

Im trying to set up Doctrine in a Zend application.
After hours of successless searching for the solution i'm desperate with this problem:

Catchable fatal error: Argument 1 passed to Doctrine\ORM\Tools\Cli\Tasks\AbstractTask::**construct() must be an 
instance of Doctrine\Common\Cli\Printers\AbstractPrinter, instance of Doctrine\Common\Cli\TaskNamespace given, called in 
C:\Users\Riplexus\Workspace\Webservice\xampp\htdocs\application\library\Doctrine\Common\Cli\TaskNamespace.php on line 88 and defined in 
C:\Users\Riplexus\Workspace\Webservice\xampp\htdocs\application\library\Doctrine\ORM\Tools\Cli\Tasks\AbstractTask.php on line 81

TaskNamespace.php:

    public function getTask($name)
    {
        // Check if task exists in namespace 
        if ($this->hasTask($name)) {
            $taskClass = $this->_tasks[self::formatName($name)];

            return new $taskClass($this); // Line 88
        }    

It happens with $name = 'ClearCache' and $taskClass = 'Doctrine\ORM\Tools\Cli\Tasks\ClearCacheTask'

Bootstrap.php:

    public function _initDoctrine() {
        require_once('Doctrine/Common/IsolatedClassLoader.php');

        $doctrineConfig = $this->getOption('doctrine');

        $classLoader = new \Doctrine\Common\IsolatedClassLoader('Doctrine');
        $classLoader->setBasePath(APPLICATION_PATH . '/../library/');
        $classLoader->register();

        $config = new \Doctrine\ORM\Configuration();

        $cache = new \Doctrine\Common\Cache\ArrayCache;
        $config->setMetadataCacheImpl($cache);
        $driver = $config->newDefaultAnnotationDriver();
        $config->setMetadataDriverImpl($driver);
        $config->setQueryCacheImpl($cache);
        $config->setProxyDir(APPLICATION_PATH . '/../Proxies');
        $config->setProxyNamespace('amoDB\Proxies');

        $connectionOptions = array(
            'driver'    => $doctrineConfig['conn']['driv'],
            'user'      => $doctrineConfig['conn']['user'],
            'password'  => $doctrineConfig['conn']['pass'],
            'dbname'    => $doctrineConfig['conn']['dbname'],
            'host'      => $doctrineConfig['conn']['host']
        );

        $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

        $registry = Zend_Registry::getInstance();
        $registry->entitymanager = $em;

        return $em;
    }

public index.php:

$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

$application->getBootstrap()->bootstrap('doctrine');
$em = $application->getBootstrap()->getResource('doctrine');

$configuration = new \Doctrine\Common\Cli\Configuration();
$configuration->setAttribute('em', $em);

$cli = new \Doctrine\Common\Cli\CliController($configuration);
$*SERVER['argv'][] = '--class-dir=' . APPLICATION*PATH . '/models';
$cli->run($_SERVER['argv']);

What additional information do you need? I have no idea, where the problem could be.

Originally created by @doctrinebot on GitHub (Jan 16, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user riplexus: Im trying to set up Doctrine in a Zend application. After hours of successless searching for the solution i'm desperate with this problem: ``` none Catchable fatal error: Argument 1 passed to Doctrine\ORM\Tools\Cli\Tasks\AbstractTask::**construct() must be an instance of Doctrine\Common\Cli\Printers\AbstractPrinter, instance of Doctrine\Common\Cli\TaskNamespace given, called in C:\Users\Riplexus\Workspace\Webservice\xampp\htdocs\application\library\Doctrine\Common\Cli\TaskNamespace.php on line 88 and defined in C:\Users\Riplexus\Workspace\Webservice\xampp\htdocs\application\library\Doctrine\ORM\Tools\Cli\Tasks\AbstractTask.php on line 81 ``` TaskNamespace.php: ``` none public function getTask($name) { // Check if task exists in namespace if ($this->hasTask($name)) { $taskClass = $this->_tasks[self::formatName($name)]; return new $taskClass($this); // Line 88 } ``` It happens with $name = 'ClearCache' and $taskClass = 'Doctrine\ORM\Tools\Cli\Tasks\ClearCacheTask' Bootstrap.php: ``` none public function _initDoctrine() { require_once('Doctrine/Common/IsolatedClassLoader.php'); $doctrineConfig = $this->getOption('doctrine'); $classLoader = new \Doctrine\Common\IsolatedClassLoader('Doctrine'); $classLoader->setBasePath(APPLICATION_PATH . '/../library/'); $classLoader->register(); $config = new \Doctrine\ORM\Configuration(); $cache = new \Doctrine\Common\Cache\ArrayCache; $config->setMetadataCacheImpl($cache); $driver = $config->newDefaultAnnotationDriver(); $config->setMetadataDriverImpl($driver); $config->setQueryCacheImpl($cache); $config->setProxyDir(APPLICATION_PATH . '/../Proxies'); $config->setProxyNamespace('amoDB\Proxies'); $connectionOptions = array( 'driver' => $doctrineConfig['conn']['driv'], 'user' => $doctrineConfig['conn']['user'], 'password' => $doctrineConfig['conn']['pass'], 'dbname' => $doctrineConfig['conn']['dbname'], 'host' => $doctrineConfig['conn']['host'] ); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $registry = Zend_Registry::getInstance(); $registry->entitymanager = $em; return $em; } ``` public index.php: ``` none $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->getBootstrap()->bootstrap('doctrine'); $em = $application->getBootstrap()->getResource('doctrine'); $configuration = new \Doctrine\Common\Cli\Configuration(); $configuration->setAttribute('em', $em); $cli = new \Doctrine\Common\Cli\CliController($configuration); $*SERVER['argv'][] = '--class-dir=' . APPLICATION*PATH . '/models'; $cli->run($_SERVER['argv']); ``` What additional information do you need? I have no idea, where the problem could be.
admin added the Bug label 2026-01-22 13:06:48 +01:00
admin closed this issue 2026-01-22 13:06:49 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 17, 2011):

Comment created by @beberlei:

You seem to use Alpha 2 or earlier. Where did you get this code from? Download the current code from github or the downloads section of the website please.

@doctrinebot commented on GitHub (Jan 17, 2011): Comment created by @beberlei: You seem to use Alpha 2 or earlier. Where did you get this code from? Download the current code from github or the downloads section of the website please.
Author
Owner

@doctrinebot commented on GitHub (Jan 17, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 17, 2011): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1234