Doctrine ORM 1.2.4 in Fuel PHP 1.1

Today, I decided to make an attempt to dive into a new framework and implement my favorite ORM framework, Doctrine. As you can see, I’ve been spoiled really hard by Doctrine and I’ve perhaps reached a point in my career where it could be best to use it to hasten the development process and of course, one of its key points of being a powerful ORM framework.

The first thing you need to do is make fuelPHP work on your box. Once ready, download Doctrine 1.2.4 here:

On a default fuelPHP installation, extract the doctrine source files into [www]/fuel/packages. You should see something similar:

Create the bootstrap file “bootstrap.php” and it should be placed in the [www]/fuel/packages/doctrine/ folder:

file: [www]/fuel/packages/doctrine/bootstrap.php
[cc lang=”php” tab_size=”2″ lines=”-1″]
setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);

$config = Config::get(“db”);

$dsn = $config[“default”][“connection”][“dsn”];
$user = $config[“default”][“connection”][“username”];
$password = $config[“default”][“connection”][“password”];

$dbh = new PDO($dsn, $user, $password);

$conn = Doctrine_Manager::connection($dbh);

By looking at the bootstrap file, Doctrine uses the database configuration of fuelPHP so that you don’t have to specify the connection details again when loading Doctrine leaving the configuration in one place.

Modify your fuelPHP config file by adding the doctrine package.
file: [www]/fuel/app/config/config.php
[cc lang=”php” tab_size=”2″ lines=”-1″ first_line=”187″]
‘packages’ => array(

And finally, test!
This is just a sample code that will let you know if Doctrine is connecting to your database properly. If configured correctly, you should be able to see the tables in your database.
[cc lang=”php” tab_size=”2″ lines=”-1″]
function action_doctrine()
$path = Doctrine::getPath();

$conn = Doctrine_Manager::connection();
$result = $conn->execute(‘SHOW TABLES;’)->fetchAll();
$tables_found = null;

foreach ($result as $table)
$tables_found .= $table[0].”

$disp = “doctrine loaded from: {$path}”;
$disp .= “

parsing tables… tables found: “;
$disp .= “



return $disp;

This should get you started with your Indoctrinated FuelPHP project!

It still does not work on my box! What do I do???
– check your configurations. verify the username, password and dsn connection
– check the extract paths
– post a comment and I’ll try to check

Packages used:
– Doctrine ORM v1.2.4
– FuelPHP v1.1

Platform (tested):
– xampp v1.7.7 on windows 7 – 64-bit
– php v5.3.8
– mysql v5.5.16

Questions / Suggestions? Ask!