Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Après y avoir passé le week-end et grâce à votre aide, j'ai réussis à intégrer Doctrine à Zend. Je présente ici un premier tuto permettant justement l'intégration de Doctrine. La suite devrait arriver prochainement.
http://www.throrinstudio.com/zf/introdu … -doctrine/
Dernière modification par throrin19 (13-09-2011 14:37:56)
Hors ligne
Je savais qu'à faire de trainer pour faire mes articles sur ZF et doctrine j'allais me faire coiffer au poteaux ^^
De toute manière, personne ne se plaindra d'avoir trop d'information.
Hors ligne
je suis tout à fait d'accord. Et puis chaque personne intègre Doctrine à sa sauce donc c'est toujours utile de voir la méthode de chacun
Hors ligne
Salut throrin,
je viens de mettre en place Doctrine grâce à ton tuto mais je ne vois pas ce qu'il y a dans le script Doctrine.php qu'il y a dans le répertoire library et aussi ce qu'il y a dans le scripts Doctrine.php qu'il y a dans le répertoire application/scripts.
Si tu as quelques minutes à m'acordder pour me dire ce qu'il y dans ces scripts sa serait super cool !!!
Hors ligne
Doctrine.php qu'il y a dans library, c'est la classe maitresse de la library Doctrine
Celui qu'il y a dans script permet de générer tes models et d'utiliser en ligne de commande les fonctions de doctrine
Hors ligne
Merci Throrin, Doctrine.php on le récupère dans le package Doctrine dans le répertoire bin ou il faut le créer soit même ?
Hors ligne
@thorin19
Très bon tutoriel, alors ...
Ce qui m'interesse c'est la version 2.0 de Doctrine.
Y à t il quelqu'un pour cela ?
Dernière modification par phibau (09-01-2011 20:33:51)
j'avais regardé la 2.0 à l'époque de la béta 1 ou 2, j'avais réussi à partiellement l'intégrer mais certaines fonctionnalités ne marchaient pas. Il faudrai que je rééssaie quand j'aurai le temps mais dans l'ensemble ça s'articule de la même façon pour l'intégrer
Hors ligne
Hello,
Je ne suis pas certain que cela s'articule de la même façon. Il y a un webinar récent de ZF1+Doctrine2 (http://www.zend.com/en/resources/webinars/) ainsi qu'un dépôt GitHub avec le code associé (https://github.com/ralphschindler/NOLASnowball).
@+
Hors ligne
Hello! je vais tester cela
https://github.com/marsbomber/zf1-doctrine2
C'est une application prête à l'emploi avec Zend Framework.
# Zend Framework 1 Integration with Doctrine 2
This project demonstrates how you can integrate Zend Framework 1.10.X with
one of the most popular PHP ORM framework, Doctrine 2.
The ZF 1 and Doctrine 2 integration work is done by Giorgio Sironi. I borrowed the source
code from Giogio's [nakedphp](http://code.google.com/p/nakedphp/) project.
The easy to use "Application_Api_Util_Bootstrap" class is the good work from [Leonard Dronkers](http://www.sreknord.net/).
As the author of this project, I take no credit in all the good work done by Giogio and Leonard.
I simply put them together into a bare bone Zend Framework project.
By putting this project on Github, I hope it could save other people some time in
finding ways to integrate ZF 1 and Doctrine 2.
Dernière modification par phibau (10-01-2011 17:42:04)
Ca pouasse l'exemple... a croire que certains ne testent jamais leur programme.
Voir de ce côté là aussi:
http://framework.zend.com/wiki/display/ … in+Eberlei
Sinon je vais devoir changer de nationalité:
http://www.oelerich.org/?p=193
Dernière modification par phibau (10-01-2011 18:10:30)
moi j'ai fais un mélange de tous ceux que @phibau a listé et voici ce que j'avais dans mon Bootstrap.php pour que ça marche:
public function _initDoctrine() { require_once('Doctrine/Common/ClassLoader.php'); $doctrineConfig = $this->getOption('doctrine'); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->setIncludePath(APPLICATION_PATH . '/../library/'); $classLoader->register(); if (APPLICATION_ENV == 'development') { $cache = new \Doctrine\Common\Cache\ArrayCache; } else { $cache = new \Doctrine\Common\Cache\ApcCache; } $entitiesPath = APPLICATION_PATH.'/models/Entities'; $proxiesPath = APPLICATION_PATH.'/models/Proxies'; $config = new \Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver($entitiesPath); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir($proxiesPath); $config->setProxyNamespace('domain\Proxies'); if (APPLICATION_ENV == 'development') { $config->setAutoGenerateProxyClasses(true); } else { $config->setAutoGenerateProxyClasses(false); } $doctrineConfig = $this->getOption('doctrine'); $connectionOptions = array( 'driver' => $doctrineConfig['conn']['driver'], 'user' => $doctrineConfig['conn']['user'], 'password' => $doctrineConfig['conn']['pass'], 'dbname' => $doctrineConfig['conn']['dbname'], 'host' => $doctrineConfig['conn']['host'], 'charset' => 'UTF8', 'driverOptions' => array( 'charset' => 'UTF8' ) ); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $em->getEventManager()->addEventSubscriber(new Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')); Zend_Registry::set('em', $em); return $em; }
La variable em remplace le Doctrine_Connection de Doctrine 1. Après je ne sais plus trop comment ça fonctionne, ça date de juin/juillet et j'ai abandonné car Doctrine 2 permet pas la génération des models à partir d'une base existante.
Hors ligne
@thorin9
Pourquoi ais je l'erreur à la ligne 33
$driverImpl = $config->newDefaultAnnotationDriver($entitiesPath);
Fatal error: Call to undefined method Doctrine\ORM\Configuration::newDefaultAnnotationDriver() in /var/www/marsbomber/application/Bootstrap.php on line 33
Dernière modification par phibau (11-01-2011 11:58:43)
oula la méthode a l'air de ne plus exister ils ont dû la supprimer depuis la beta1.
Hors ligne
@thorin9
C'est la librairie de marsbomber qui ne vas pas
J'ai mis la vraie de Docrine mais j'ai quand même un souci
Zend Server me donne ce message d'erreur:
0 /var/www/marsbomber/library/Doctrine/DBAL/DriverManager.php(147): Doctrine\DBAL\DBALException::driverRequired()
#1 /var/www/marsbomber/library/Doctrine/DBAL/DriverManager.php(114): Doctrine\DBAL\DriverManager::_checkParams(Array)
#2 /var/www/marsbomber/library/Doctrine/ORM/EntityManager.php(718): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\ORM\Configuration), Object(Doctrine\Common\EventManager))
#3 /var/www/marsbomber/application/Bootstrap.php(58): Doctrine\ORM\EntityManager::create(Array, Object(Doctrine\ORM\Configuration))
#4 /var/www/marsbomber/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initDoctrine()
#5 /var/www/marsbomber/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Appli in /var/www/marsbomber/library/Doctrine/DBAL/DBALException.php on line 29
Je travaille dessus pour comprendre
Dernière modification par phibau (11-01-2011 14:42:18)
(je travaille averc l'exemple de marsbomber)
Je viens de résouire le problème et je n'ai pluis d'erreur:
J'ai enlevé le _initDoctrine et j'ai placé cela dans application.ini
resources.entitymanagerfactory.cache = "Doctrine\Common\Cache\ArrayCache"
resources.entitymanagerfactory.metadata.classDirectory = APPLICATION_PATH "/models/"
resources.entitymanagerfactory.metadata.driver = "annotation"
resources.entitymanagerfactory.proxyDir = APPLICATION_PATH "/proxies/"
resources.entitymanagerfactory.proxyNamespace = "Application_Proxies"
resources.entitymanagerfactory.autoGenerateProxyClasses = true
resources.entitymanagerfactory.useCExtension = false
resources.entitymanagerfactory.connectionOptions.driver = "pdo_mysql"
resources.entitymanagerfactory.connectionOptions.user = "root"
resources.entitymanagerfactory.connectionOptions.password = "xxxx"
resources.entitymanagerfactory.connectionOptions.dbname = "square"
resources.entitymanagerfactory.connectionOptions.host = "localhost"
Evidemment j'ai une autre erreur ailleurs mais elle provient de ZendX...
Bon je vais m'avaler la documentation et je reviens faire un exemple qui tourne.
Dernière modification par phibau (11-01-2011 15:09:22)
suite http://www.z-f.fr/forum/viewtopic.php?id=6133
Dernière modification par phibau (11-01-2011 21:39:51)