Doctrine Generate Models from DB

Automatically generating the models for a project based off of existing database tables is extremely handy. I’ve had to do this several times and the available options are key, especially when generating these for a Zend Framework layout. The following stack overflow entry is very helpful:

* Doctrine CLI script

define('APPLICATION_ENV', 'development');

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../library/Doctrine'),

require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_PATH . '/config/default.ini'


APPLICATION_PATH . '/modules/default/models/DbTable',
'pearStyle' => true,
'generateTableClasses' => true,
'baseClassesDirectory' => '',
'classPrefix'=> 'Model_DbTable_',
'classPrefixFiles' => false,
'baseClassPrefix' => 'Generated_'

Tuesday, November 15th, 2011 Doctrine, Zend Framework

Leave a Reply

You must be logged in to post a comment.

[ad code=1 align=center]