i am following the tutorial from http://www.zendcasts.com/introducing-doctrine-1-2-integration/2009/11/
i have a doctrine.php that "bootstraps?" doctrine ... sry i dont really fully understand the tut yet
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..'));
// 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');
$config = $application->getOption('doctrine');
$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);
when i try to run it via cmd,
php.exe doctrine.php
i get
D:\Projects\ZF\doctrine\application\scripts>php -f doctrine.php
PHP Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static met
hod (class 'Doctrine' not found)' in D:\Projects\ZF\doctrine\application\Bootstrap.php:7
Stack trace:
#0 D:\Projects\ZF\doctrine\application\Bootstrap.php(7): spl_autoload_register(Array)
#1 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(662): Bootstrap-
>_initDoctrine()
#2 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(622): Zend_Appli
cation_Bootstrap_BootstrapAbstract->_executeResource('doctrine')
#3 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(579): Zend_Appli
cation_Bootstrap_BootstrapAbstract->_bootstrap('doctrine')
#4 D:\Projects\ZF\doctrine\application\scripts\doctrine.php(25): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap
('doctrine')
#5 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Loader.php(136): include('D:\Projects\ZF in D:\Projects\ZF\d
octrine\application\Bootstrap.php on line 0
.
UPDATE 1
.
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);
$doctrineConfig = $this->getOption("doctrine");
$conn = Doctrine_Manager::connection($doctrineConfig['dsn']);
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
return $conn;
}
under sql_autoload_register() i guess. i dont really get what spl_autoload_register() also ... even in php reference
UPDATE 2
my bootstrap.php
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
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);
$doctrineConfig = $this->getOption("doctrine");
Doctrine::loadModels($doctrineConfig['models_path']);
$conn = Doctrine_Manager::connection($doctrineConfig['dsn'], 'Doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
return $conn;
}
}
i guess the thing thats not working is Zend does not seem to autoload the Doctrine class. which its supposed to cos i already have registered the Doctrine namespace in config.ini
autoloaderNamespaces[] = "Doctrine"
does this mean Zend shld autoload Doctrine classes?
as for where Doctrine is stored, i have pointed to it inside PHP's include path.
include_path = ".;c:\php\includes;D:\ResourceLibrary\Frameworks\ZendFramework\library;D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib"
i noted that if in _initDoctrine(), i require Doctrine manually it works.
require_once 'D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib\Doctrine.php';
has it got something to do with windows path (\ as separator)