Kohana Doctrine integration

This module allows the Doctrine OR/M to be used with Kohana.

IMPORTANT!

I don't provide support for using Doctrine. If you find bugs in the integration of Doctrine into Kohana then please let me know, and I will fix them. I cannot help you use Doctrine - if you have problems please read their manual or ask on their mailing list.

Download

Download 0.2

INSTALL

  1. Extract the file you've downloaded
  2. Copy it over the top of your Kohana installation.
  3. You now need to install Doctrine. It needs to go in the modules/doctrine/vendor folder. Please see their instructions for getting Doctrine - I manage my Kohana projects using SVN and so use the svn:externals method. If you want to do it my way:
    • Delete the vendor folder
    • edit the SVN properties on modules/doctrine and set svn:externals to vendor http://svn.phpdoctrine.org/branches/0.10/lib
    • Run a svn update
    You will end up with a file modules/doctrine/vendor/Doctrine.php and a directory containing lots of files at modules/doctrine/vendor/Doctrine/
  4. If running on Unix or Linux, set modules/doctrine/doctrine to be executable (755)
  5. Enable hooks, or load modules/doctrine/hooks/doctrine.php
  6. Create your schema in application/config/doctrine/schema
  7. Open a command window and go to modules/doctrine. Run the doctrine command from the prompt:
    > doctrine
    or on Windows
    > C:\path\to\php.exe doctrine
    And choose the command you want.

FAQ

Q: Why does adding doctrine put folders in application/ as well as modules/?

This is something I thought about deeply before deciding to do it. As I see it, a module is self-contained code which should be independent of the current application. In the case of doctrine, this is the library, hook, and command-line interface.

The schema files, models and fixtures are application specific, therefore reside in the application directory.

This means that the module can be copied from one Kohana installation to another can not carry any application specific data with it. It does however mean the folders in application/config/doctrine have to be recreated each time.

I did post in the Kohana Forum before starting to see if my understanding of the separation between application and modules was correct but didn't receive much helpful feedback

Q: Why do you not include doctrine with this module?

Doctrine is under heavy development, and if I included it with this module it would always be out of date. Not including doctrine allows you to use a SVN checkout without having to delete doctrine first. The best way to get Doctrine is to download it directly from http://phpdoctrine.org. This way you will always get the latest version.

I use a SVN checkout of Doctrine (pinned to the 0.10 branch) so I get bug fixes whenever they're made, and I recommend you do the same.

Q: Why are models put in application/models/doctrine not application/models?

Good question! I don't like them in a sub-directory, however (mostly because of legacy code issues from models we're moving from CodeIgniter) if doctrine models went in the same directory as the Kohana models the command-line tools wouldn't work, as they expect to load and inspect all models when generating the SQL.

Do you think all models should be in application/models? Let me know!