I would like to start developing with Zend Framework and I would like to use zf2. Since I use Doctrine 2, can you suggest some tutorials to help me to integrate it in zf2? Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
last time checked: ZF2.2.*, DoctrineORMModule 0.7.
Official Module
You may want to load
DoctrineORMModulevia composer:doctrine/doctrine-orm-moduleto your composer.json‘s require (example code after list bcs of formatting problems)php composer.phar install./data/DoctrineORMModule/Proxyand ensure write access for your application/config/autoloadto give the module the project-specific settings (database etc)config.phpDoctrineORMModuleandDoctrineModuleto yourconfig/application.config.php./vendor/bin/doctrine-module orm:schema-tool:createI strongly discourage you from not using composer, as it is an easy way to install dependencies and have the autoloaders all set up. Also ZF2 ships via composer by default.
Example Code
composer.json
entities settings
A gotcha to be aware of: The paths to your entites should be fully qualified. Best start with
__DIR__, else things will break (Every new project I wonder why the command line tool doesn’t work until I find this error … 😉connection settings
All code examples are part of the official doctrine module readme
Further Reading:
Marco Pivetta made a wonderful presentation about doctrine-module usage, which I recommend to everybody using this module.
Jason Grimes wrote a tutorial featured on phpdeveloper.org which should help installing doctrine, before there was an official module.