<< A few updates for 2008 Doctrine all grown up >>

Using Doctrine with CodeIgniter

Using Doctrine with CodeIgniter

Posted by jwage 4 months ago.

If you use the PHP MVC framework, CodeIgniter, and want to use Doctrine, here is a tutorial on how to integrate Doctrine with your CodeIgniter applications. It was fairly simple and took me about 15 minutes to figure out a nice and clean implementation. The wiki page can be found here.


Comments (6) [ add comment ]

hm - Posted by skolman about 4 months ago.

how to integrate doctrine with zend framework? any links?

Posted by jwage about 3 months ago.

It would be done much the same way it was done in code igniter. You must require Doctrine.php and set the autoloader. If I have time I might put together a tutorial on how to do it. It would only take 10-15 minutes.

Posted by jwage about 3 months ago.

Someone started one here:

http://www.spotsec.com/blog/archive/2007/12/12/integrating-doctrine-orm-with-zend-framework/

I will keep checking it, when it is finished I will post it on the phpdoctrine blog.

Posted by hmmm about 3 months ago.

The above link only has two lines of code, require_once(Doctrine.php); spl_auto_upload(...);
It doesn't look like a good tutorial to me. Jwage, if you can do it in 10-15 minutes, why not make one tutorial?

Posted by tiago.bar about 3 months ago.

Any info how to integrate doctrine with CakePHP?

Posted by jwage about 3 months ago.

That is all it takes to integrate with Zend. Zend is ORM agnostic, so the core does not rely on any specific database functionality. Once Doctrine.php is required and autoloader is set, Doctrine is ready to go at your finger tips.

The next thing to do would be to create your models/schema files. If you build your schema files, you can generate your models from the schema by using the command line interface. Here you can read about how to implement a command line interface anywhere. http://www.phpdoctrine.org/documentation/manual/0_10?one-page#utilities:command-line-interface

If you prefer not to use the command line interface, you can setup your own scripts which call the core Doctrine code. You can read about the Doctrine facade here: http://www.phpdoctrine.org/documentation/manual/0_10?one-page#utilities:facade

It has functions like generateModelsFromDb(), generateModelsFromYaml(), generateYamlFromDb(), etc. The command line interface essentially calls all the the core facade functions, they are just wrapped in a nice command line interface task system which can be execute from the cli or any other interface in a standardized way.

As far as cakePHP goes, Cake is pretty reliant on the database and the cake native modeling, so if you were to use Doctrine instead of native modeling, you would lose all the magic helpers/features that you get in Cake. But you could easily get around this by creating some kind of plugin which recreates all the magic of cake but while using Doctrine.

Add Comment

Add New Comment
Please enter 'follow the doctrine' without the quotes