Hi,

I am trying to use Zend to load Doctrine but I can't make it work.

I am executing the script

// Define path to application directory

defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', dirname(__FILE__) . '/../../application');

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

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

$application->getBootstrap()->bootstrap("doctrine");

$cli = new Doctrine_Cli($application->getOption('doctrine'));
$cli->run($_SERVER['argv']);

The error is below.

PHP Fatal error:  Uncaught exception
'Zend_Application_Bootstrap_Exception' with message 'Resource matching
"doctrine" not found' in
/usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/BootstrapAbstract.php:692
Stack trace:
#0 
/usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/BootstrapAbstract.php(627):
Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('doctrine')
#1 
/usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/BootstrapAbstract.php(584):
Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap('doctrine')
#2 /Users/rt/Sites/myapp/application/scripts/doctrine.php(26):
Zend_Application_Bootstrap_BootstrapAbstract->bootstrap('doctrine')
#3 /Users/rt/Sites/myapp/application/scripts/doctrine(4):
include('/Users/rt/S...')
#4 {main}
  thrown in 
/usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/BootstrapAbstract.php
on line 692

In my Bootstrap.php

protected function __initDoctrine()
    {
        $this->getApplication()->getAutoloader()
                               ->pushAutoloader(array('Doctrine', 'autoload'));
        spl_autoload_register(array('Doctrine', 'modelsAutoload'));
        $manager = Doctrine_Manager::getInstance();
        $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
        $manager->setAttribute(
            Doctrine::ATTR_MODEL_LOADING,
            Doctrine::MODEL_LOADING_CONSERVATIVE
        );
        $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
        $manager->setCollate('utf8_unicode_ci');
        $manager->setCharset('utf8');

        $doctrine = $this->getOption('doctrine');
        $conn = Doctrine_Manager::connection($doctrine['dsn'], 'doctrine');
        $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
        return $conn;
    }

And under application.ini (production)

doctrine.dsn = "mysql://root:crazypassword:localhost/db"
doctrine.data_fixtures_path = APPLICATION_PATH "/configs/data/fixtures"
doctrine.sql_path           = APPLICATION_PATH "/configs/data/sql"
doctrine.migrations_path    = APPLICATION_PATH "/configs/migrations"
doctrine.yaml_schema_path   = APPLICATION_PATH "/configs/schema.yml"
doctrine.models_path        = APPLICATION_PATH "/models"

Any ideas?

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to