Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework, Doctrine Help needed
    text
    copied!<p>I am following the tutorial from <a href="http://www.zendcasts.com/introducing-doctrine-1-2-integration/2009/11/" rel="nofollow noreferrer">Introducing Doctrine 1.2 Integration</a></p> <p>I have a doctrine.php that "bootstraps?" doctrine ... sorry I don't really fully understand the tutorial yet.</p> <pre><code>// 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-&gt;getBootstrap()-&gt;bootstrap('doctrine'); $config = $application-&gt;getOption('doctrine'); $cli = new Doctrine_Cli($config); $cli-&gt;run($_SERVER['argv']); </code></pre> <p>when I try to run it via cmd, </p> <pre><code>php.exe doctrine.php </code></pre> <p>I got </p> <pre><code>D:\Projects\ZF\doctrine\application\scripts&gt;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- &gt;_initDoctrine() #2 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(622): Zend_Appli cation_Bootstrap_BootstrapAbstract-&gt;_executeResource('doctrine') #3 D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(579): Zend_Appli cation_Bootstrap_BootstrapAbstract-&gt;_bootstrap('doctrine') #4 D:\Projects\ZF\doctrine\application\scripts\doctrine.php(25): Zend_Application_Bootstrap_BootstrapAbstract-&gt;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 </code></pre> <p><strong>Update 1</strong></p> <pre><code>protected function _initDoctrine() { $this-&gt;getApplication()-&gt;getAutoloader() -&gt;pushAutoloader(array('Doctrine', 'autoload')); spl_autoload_register(array('Doctrine', 'modelsAutoload')); $manager = Doctrine_Manager::getInstance(); $manager-&gt;setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); $manager-&gt;setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); $manager-&gt;setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true); $doctrineConfig = $this-&gt;getOption("doctrine"); $conn = Doctrine_Manager::connection($doctrineConfig['dsn']); $conn-&gt;setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); return $conn; } </code></pre> <p>under <code>sql\_autoload\_register()</code> I guess. I don't really get what <code>spl\_autoload\_register()</code> also ... even in php reference.</p> <p><strong>Update 2</strong></p> <p>my bootstrap.php</p> <pre><code>&lt;?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initDoctrine() { $this-&gt;getApplication()-&gt;getAutoloader() -&gt;pushAutoloader(array('Doctrine', 'autoload')); spl_autoload_register(array('Doctrine', 'modelsAutoload')); $manager = Doctrine_Manager::getInstance(); $manager-&gt;setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); $manager-&gt;setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); $manager-&gt;setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true); $doctrineConfig = $this-&gt;getOption("doctrine"); Doctrine::loadModels($doctrineConfig['models_path']); $conn = Doctrine_Manager::connection($doctrineConfig['dsn'], 'Doctrine'); $conn-&gt;setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); return $conn; } } </code></pre> <p>I guess the thing thats not working is Zend does not seem to autoload the Doctrine class. which its supposed to because I already have registered the Doctrine namespace in config.ini</p> <pre><code>autoloaderNamespaces[] = "Doctrine" </code></pre> <p>Does this mean Zend shld autoload Doctrine classes? </p> <p>as for where Doctrine is stored, i have pointed to it inside PHP's include path. </p> <blockquote> <p>include_path = ".;c:\php\includes;D:\ResourceLibrary\Frameworks\ZendFramework\library;D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib"</p> </blockquote> <p>I noted that if in <code>_initDoctrine()</code>, I require Doctrine manually it works. </p> <pre><code>require_once 'D:\ResourceLibrary\Frameworks\Doctrine121sandbox\lib\Doctrine.php'; </code></pre> <p>has it got something to do with windows path (\ as separator)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload