Requirements:
* A database supported by Doctrine
* CodeIgniter (tested on v1.7)
* PHP5
* A working PDO library for your database of choice
Installation:
1. Drop this extracted directory into the plugins folder of your CI system directory.
2. Create a directory within your application folder called “doctrine”
2a. Create three directories within this doctrine directory named “fixtures”, “models”, and “schema”. Make sure the “models” directory has full write access (chmod 777)
4. Configure your database connection as you would for CodeIgniter
The schema directory will be where the Doctrine plugin will look for your yaml schema files as per the Doctrine manual. Models generated from those yaml files will be saved in the models directory (which is why the directory must have full write access). The fixtures directory contains any fixture data you may want to include: this data will be inserted into the database whenever the doctrine_populate_database method is called (more on that below).
Configuration:
The Doctrine plugin uses the database information as it exists in the database configuration file (/system/application/config/database.php). It should require zero configuration to install properly.
Using Doctrine:
To use Doctrine, you must first load the plugin into CodeIgniter. This can be done with “$this->load->plugin(‘doctrine’)”. From there, you gain access to the the full doctrine API, which should behave very much like a typical PHP project. In addition, there are some useful convenience functions added to the plugin file that make development (particularly developing schema and fixture information) more expedient.
The primary ones are doctrine_install, doctrine_uninstall, and doctrine_reinstall. The install function will generate model files from the schema yaml, then instantiate the database using the CI configuration files, then insert the fixture data. Uninstall will do just the opposite: it will drop all the tables that were created by Doctrine and delete all the model files.
You can control the order in which these things take place with a set of utility functions:
doctrine_create_database: Creates the database from the doctrine model files it finds in the models directory. If there are no models in this directory, it will run doctrine_create_models before generating the database.
doctrine_populate_database: Populates the database with data defined in your fixtures directory. Requires an installed database and generated models. It does not generate these things automatically.
doctrine_destroy_database: Drops all tables created by Doctrine. Any tables that were not created or maintained by Doctrine will not be deleted.
doctrine_create_models: Generates model files from the schema files found in the schema directory.
doctrine_destroy_models: Deletes all files in the doctrine models directory.
Troubleshooting:
If you are unable to run the install function successfully, and are running Mac OS X, check if there is a .DS_Store file in your doctrine models directory. If so, delete it.