Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can give you some examples from the bootstrap.php I use:</p> <pre><code> public function _initDoctrine() { if(PHP_MAJOR_VERSION == 5 &amp;&amp; PHP_MINOR_VERSION &gt;= 3) { require_once('bootstrapDoctrine.inc.php'); //things below this line are for convenience require_once(dirname(__FILE__).'/../library/doctrinehelpers/requireEntitiesOnce.php'); Zend_Registry::set('doctrineEm', $em); return $em; } } </code></pre> <p>And in the boostrapDoctrine.inc.php I have this:</p> <pre><code>use Doctrine\Common\ClassLoader, Doctrine\ORM\Configuration, Doctrine\ORM\EntityManager, Doctrine\Common\Cache\ArrayCache, Doctrine\DBAL\Logging\EchoSQLLogger; require_once(realpath(APPLICATION_PATH . '/../library').'/doctrine2/lib/Doctrine/Common/ClassLoader.php'); $doctrineClassLoader = new ClassLoader('Doctrine', realpath(APPLICATION_PATH . '/../library').'/doctrine2/lib'); $doctrineClassLoader-&gt;register(); //no way to have your proxies generated in different directory per ZF module it seems so we use a global one $proxiesClassLoader = new ClassLoader('Proxies', realpath(APPLICATION_PATH . '/models/doctrineproxies')); $proxiesClassLoader-&gt;register(); /* * @TODO make this step iterate over available modules */ $driverImpl = $config-&gt;newDefaultAnnotationDriver(array(APPLICATION_PATH . '/modules/mymodule1/models/doctrineentities',APPLICATION_PATH . '/modules/mymodule2/models/doctrineentities')); $config-&gt;setMetadataDriverImpl($driverImpl); $config-&gt;setMetadataCacheImpl($cache); $config-&gt;setQueryCacheImpl($cache); // Proxy configuration $config-&gt;setProxyDir(realpath(APPLICATION_PATH . '/models/doctrineproxies')); $config-&gt;setProxyNamespace('Proxies'); /** * this SQL logger is golden * @TODO implement a switch for verbose debugging */ // $logger = new Doctrine\DBAL\Logging\DebugStack(); // $config-&gt;setSQLLogger($logger); // register_shutdown_function(function($logger) { // echo '&lt;pre&gt;'; // print_r($logger-&gt;queries); // }, $logger); $config-&gt;setAutoGenerateProxyClasses( true ); //disable in production environment $doctrineConfig = $this-&gt;getOption('resources'); //from ini $dbparams = $doctrineConfig['db']['params']; $connectionOptions = array( 'driver' =&gt; $doctrineConfig['db']['adapter'], 'user' =&gt; $dbparams['username'], 'password' =&gt; $dbparams['password'], 'dbname' =&gt; $dbparams['dbname'], 'host' =&gt; $dbparams['host'] ); $em = EntityManager::create($connectionOptions, $config); //stored in zend registry later </code></pre> <p>To allow the doctrine commandline tool to function I had to create a library/doctrine2/lib/cli-config.php which is also a stripped down zend framework bootstrap. This config has the disadvantage that I have to call the doctrine cli from within this directory. Works for me ;)</p> <p> <pre><code>/* * @TODO make the cli-tool more flexible by better path detection */ // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(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'), realpath(APPLICATION_PATH . '/../../include'), 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'); $em = $application-&gt;getBootstrap()-&gt;getResource('doctrine'); /* $configuration = new \Doctrine\Common\Cli\Configuration(); $configuration-&gt;setAttribute('em', $em); */ $helperSet = new \Symfony\Components\Console\Helper\HelperSet(array( 'db' =&gt; new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em-&gt;getConnection()), 'em' =&gt; new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) )); </code></pre> <p>Now we are all hoping for a better doctrine integration but this will only happen in ZF 2 going a big step towards namespaces like doctrine did allready.</p> <p>Hope I could help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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