I'm trying to set up Doctrine 2 to play with ZF 1.11 for a while. I have managed to resolve all errors except one:
PHP Fatal error: Class 'Doctrine\ORM\Configuration' not found in C:\development\porjects\application\Bootstrap.php on line 258
Below is the _iniDoctrine() function in the Bootstrap.php file up to the line 258 referred to by the error message:
protected function _initDoctrine()
{
$this->bootstrap('autoload');
require_once('Doctrine/Common/ClassLoader.php');
// Create the doctrine autoloader and remove it from the spl autoload stack (it adds itself)
require_once 'Doctrine/Common/ClassLoader.php';
$doctrineAutoloader = array(new \Doctrine\Common\ClassLoader(), 'loadClass');
spl_autoload_unregister($doctrineAutoloader);
$autoloader = Zend_Loader_Autoloader::getInstance();
// Push the doctrine autoloader to load for the Doctrine\ namespace
$autoloader->pushAutoloader($doctrineAutoloader, 'doctrine');
$classLoader = new \Doctrine\Common\ClassLoader('Entities', realpath(__DIR__ . '开发者_开发技巧/models/'), 'loadClass');
$autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Entities');
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../library/Doctrine/'), 'loadClass');
$autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Symfony');
$doctrineConfig = $this->getOption('doctrine');
$config = new \Doctrine\ORM\Configuration();
Apparently, the application fails to 'see' the Configuration class (and file). If I manually require the class before the class is instantiated. Another Class/file appears 'unseen'. A 'manual' fix definitely would not do.
The Doctrine folder which contains these files is on my include path. I have scoured the web for ideas. What please would you suggest? Thanks
I achieve to make ZF 1.x & Doctrine 2 working great together using this application resource it is available on github and well documented.
Hope that helps
If you are looking to integrate Doctrine 2 + Zend Framework you might want to use the 'glue' provided by one of the Doctrine developers (Guilherme Blanco) https://github.com/guilhermeblanco/ZendFramework1-Doctrine2
If you haven't seen the presentation by Ralph Schindler and Guilherme Blanco, there is one on Slideshare. http://www.slideshare.net/ralphschindler/zend-framework-1-doctrine-2-6177485
Also, Ralph has a nice example application on Github. https://github.com/ralphschindler/NOLASnowball/tree/doctrine2-managed-crud#
There's also a great screencast at ZendCasts on how to implement Guilerme's adapter. Look for Unit Testing Doctrine 2 Entities.
精彩评论