I Introducing Doctrine 1.2 Integration adlı öğretici takip ediyorum
Ben bir doctrine.php var "özyüklenirler?" Olduğunu doktrin ... üzgünüm gerçekten henüz tam öğretici anlamıyorum.
// 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']);
Ben cmd yoluyla çalıştırmayı denediğinizde,
php.exe doctrine.php
I got
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;
}
sql\_autoload\_register()
sanırım altında. Ben gerçekten ne spl\_autoload\_register()
da ... Hatta php referans alamadım.
Update 2
Benim 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;
}
}
Ben şu çalışmıyor şey Zend Doktrini sınıf autoload görünmüyor sanırım. hangi onun zaten config.ini yılında Doktrini ad kayıtlı çünkü gerekiyordu
autoloaderNamespaces[] = "Doctrine"
Bu Zend shld özdevinimli_yükle Doktrin sınıflar anlamına mı geliyor?
Doktrin nerede saklandığını gelince, ben PHP içeride buna işaret yolunu içerir.
include_path = ".;c:\php\includes;D:\ResourceLibrary\Frameworks\ZendFramework\library;D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib"
Ben _initDoctrine()
, ben Doktrini gerekiyorsa elle çalıştığını kaydetti.
require_once 'D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib\Doctrine.php';
o (ayırıcı olarak \) pencereler yolu ile ilgili bir şey var