Misty-Stix

The Clouded Vision

Blog Hacking Misty About Contact

Blog by Category - Techy thoughts p.1

doctrine in kohana

programming

I've been using kohana and its query builder for a while now - its good but in time I came to notice that I begin rewriting code over and over again so I tried to break out of the kohana-database shell and tried out existing ORM frameworks. If you're curious about ORM check here - http://en.wikipedia.org/wiki/Object-relational_mapping. In short; using orm frameworks may greatly reduce the data-access layer code you write in your application and ensures functionality and ease in retrieving data and treating them as objects.

Without further ado; the integration of kohana and doctrine.

Instructions:
1) Download doctrine module here - http://dl.dropbox.com/u/617821/misty/doctrine.1.2.zip
2) Extract the doctrine folder to your modules directory. eg /public_html/modules/
3) Include doctrine in your modules list located in application/config/config.php
   

$config['modules'] = array
(
MODPATH.'doctrine',        // Doctrine
  // MODPATH.'archive',    // Archive utility
  // MODPATH.'payment',   // Online payments
  // MODPATH.'unit_test',    // Unit testing
);

4) Make sure you enable hooks for your particular application in application/config/config.php
   
$config['enable_hooks'] = TRUE;

5) Before running your application, create these configuration folders (be sure to set permissions to 777), doctrine will import and export doctrine-specific configurations here:
   
application/config/doctrine/sql
application/config/doctrine/fixtures
application/config/doctrine/migrations
application/config/doctrine/schema

6) Before running your application, create these models folders (be sure to set permissions to 777), doctrine will store and load your auto-generated models from here:
   
application/models/doctrine
application/models/doctrine/generated

7) Test your application. You can generate models from your database schema by executing this code:
   
Doctrine::generateModelsFromDb('application/models/doctrine', array('doctrine'), array('generateTableClasses' => true));

   
And that's pretty much it to make doctrine work with kohana. I've tested this configuration both local and online. This configuration uses the application/config/database.php so you don't have to re-specify the credentials of your database elsewhere in the application.

If it doesn't work on your end don't hesitate to let me know. =)

Other Information:
    Tested working in: Kohana v2.3.4, PHP v5.2.6, MySQL v5.0.67-community-nt
    ORM framework used: Doctrine v1.2
   
Other References:
    http://www.mapledesign.co.uk/code/kohana-doctrine/ - I got most of the idea from here
    http://www.doctrine-project.org/documentation/manual/1_2/en/introduction - doctrine documentation / manual
    http://www.kohanaphp.com/ - kohana php framework

 

misty version 3 design fixture

misty v1 to v2 banner

Before anything else, I would like thank you once again for visiting my humble website. Ok now as you can see, misty has a whole new look. Apparently it took me quite a while to finish this layout as I'm not much of a designer although sometimes i get the hang of it by staring at other 'godly' sites with awesome designs! I would wish to thank the guys at twitter for sharing inspiration that has given me a drive to do this fixture.

You might be wondering, yes this is version 3, where the hell is version 2? I'd say that version 2 was a failure, if you want to check it out then click: misty version 2. I wasn't so impressed with the way I did things so I had to scrap it. Good thing version 3 is finished and here you see it although I believe there could be more improvements to it. For those who haven't seen the previous version then click: misty version 1.

I would like to ask your opinion about the new design and if there are problems or layout issues please don't hesitate to leave a comment.

jump: 1 2