Autoloading Propel in Zend Framework

November 21st, 2009 by Justin

Lately I have been working on a new project using Zend Framework as the MVC and Propel as the database objects. I have been searching high and low for a way to autoload the Propel classes using Zend_Loader_Autoload. Turns out the solution is very simple.

Propel has it’s own built in autoloader and accessing it couldn’t be easier.

First off, locate the config file generated by propel. It would be in the /build/conf folder.
Next, include Propel.php in your main index.php.
Then run the init function and pass it the path to your config file.

require_once 'propel/Propel.php';
Propel::init("models/build/conf/mydatabase-conf.php");

After that all your files should autoload.

If you are having problems make sure your your application path and your /build/classes folder are in your include paths