开发者

Generating Doctrine2 Entities from Zend Framework causes Helper em is not defined

Good Morning,

I'm new to Doctrine2 and am attempting to integrate it with Zend Framework 1.11. I tried to generate my models using orm:generate-entities from the doctrine command line. However, when I do this, I receive the following error:

[InvalidArgumentException] The helper 'em' is not defined.

What steps must I follow to generate models and entities for use within ZF?

Here are the contents of bootstrap.php:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctrine(){
require_once('usr/share/pear/Doctrine/Common/ClassLoader.php');

$autoloader = Zend_Loader_Autoloader::getInstance();
$classLoader= new usr/share/pear/Doctrine/Common('Entities',
realpath(Ze开发者_StackOverflow中文版nd_Registry::get('config')->resources->EntityManager->connection->entities),
'LoadClass');

$autoLoader->pushAutoLoader(array($classLoader, 'LoadClass'), 'Entities');
$classLoader = new \Doctrine\Common\ClassLoader('Repositories',
    realpath(Zend_Registry::get('config')->resources->entityManager->connection->entities), 'loadClass');



$autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Repositories');     

$em=\Doctrine\ORM\EntityManager::create($options['db'],$config);
Zend_Registry::set('em',$em);

return $em;
}

Thanks much for your help!


Some options for you to choose from:

1.Check zendcasts which has useful screencasts and guids on how to integrate doctrine 2 and ZF 1 and how to use them to work with database manipulations and deep integration with zend_auth.make sure to check other screencasts too.check here for full index of screencasts.

2.Buy "EASY PHP WEBSITES WITH THE ZEND FRAMEWORK" book which is a good resource for doctrine2 integration and you may access the project files for free from the address below. in README you can find this step by step guide: 1. Clone Doctrine 2

$ git clone git://github.com/doctrine/doctrine2.git doctrine2-orm
  1. Copy the following three directories into a directory named Doctrine found in the z2d2 library directory:

    lib/Doctrine/ORM lib/vendor/doctrine-common/lib/Doctrine/Common lib/vendor/doctrine-dbal/lib/Doctrine/DBAL

  2. Copy the following directory into the z2d2 library directory:

    lib/vendor/Symfony

When done, your library directory should look like this:

library/
  Doctrine/
  Common/
  DBAL/
  ORM/
Symfony/
WJG/

You'll also need to modify the Doctrine database connection parameters and entity/proxy/repository paths. These parameters are all found in the application.ini.example file. Rename this file to application.ini before making your changes.

Finally, you'll need to use the included Doctrine CLI to generate the schemas, done from within the application directory using the following command:

$ ./scripts/doctrine orm:schema-tool:create

3.Your third option will be to use Bisna project on github.README file is clear,however i suggest you read this blog post too. Bisna project is probably the most powerful integration.For an example project which already incorporates bisna,check Zend-Framework-Starter-Kit

  git clone git://github.com/nvoyageur/Zend-Framework-Starter-Kit.git
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜