Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 19-04-2010 20:42:51

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

[ZEND 1.10]Intégration de Doctrine

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

 

#2 20-04-2010 10:18:50

armetiz
Membre
Lieu: Lyon
Date d'inscription: 26-02-2010
Messages: 53
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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

 

#3 20-04-2010 10:31:13

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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 smile

Hors ligne

 

#4 09-01-2011 16:59:41

erehcab
Membre
Date d'inscription: 17-11-2009
Messages: 63

Re: [ZEND 1.10]Intégration de Doctrine

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

 

#5 09-01-2011 18:16:32

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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 smile

Hors ligne

 

#6 09-01-2011 19:55:51

erehcab
Membre
Date d'inscription: 17-11-2009
Messages: 63

Re: [ZEND 1.10]Intégration de Doctrine

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

 

#7 09-01-2011 20:31:20

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

@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)

 

#8 10-01-2011 09:03:17

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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

 

#9 10-01-2011 10:22:42

mikaelkael
Administrateur
Lieu: Donges
Date d'inscription: 18-06-2007
Messages: 1176
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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).

@+


Less code = less bugs
Contributeur ZF - ZCE - ZFCE - Doc ZF (CHM & PDF) - Vice-trésorier AFUP 2011
Ubuntu 11.04 - ZendServer

Hors ligne

 

#10 10-01-2011 17:30:12

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

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)

 

#11 10-01-2011 18:08:40

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

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)

 

#12 10-01-2011 19:00:18

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZEND 1.10]Intégration de Doctrine

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:

Code:

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

 

#13 11-01-2011 11:57:59

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

@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)

 

#14 11-01-2011 12:01:36

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZEND 1.10]Intégration de Doctrine

oula la méthode a l'air de ne plus exister sad ils ont dû la supprimer depuis la beta1.

Hors ligne

 

#15 11-01-2011 14:41:10

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

@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)

 

#16 11-01-2011 15:08:16

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

(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)

 

#17 11-01-2011 21:39:03

u.del.01
Invité

Re: [ZEND 1.10]Intégration de Doctrine

suite http://www.z-f.fr/forum/viewtopic.php?id=6133

Dernière modification par phibau (11-01-2011 21:39:51)

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages