Hello everyone,
I am attempting to configure the doctrine cli to properly create/populate my
db and generate zf-compatible models based on a schema yaml file.
However, when I run my model builder script I encounter the following error:
PHP Fatal error: Cannot redeclare class Default_Model_BaseGroup in D:\Web
Server Root\Projects\mysite\application\modules\default\models\BaseGroup.php
on line 47
Below are my specific details, any help would be greatly appreciated.
===
output
===
php rebuild_models.php build-all-reload
build-all-reload - Are you sure you wish to drop your databases? (y/n)
y
build-all-reload - Successfully dropped database for connection named
'doctrine'
build-all-reload - Generated models successfully from YAML schema
build-all-reload - Successfully created database for connection named
'doctrine'
build-all-reload - Created tables successfully
PHP Fatal error: Cannot redeclare class Default_Model_BaseGroup in D:\Web
Server Root\Projects\mysite\application\modules\default\models\BaseGroup.php
on line 47
Fatal error: Cannot redeclare class Default_Model_BaseGroup in D:\Web Server
Root\Projects\mysite\application\modules\default\models \BaseGroup.php on
line 47
===
end output
===
===
System Information
====
Apache/2.2.11 (Win32)
PHP/5.2.10
Doctrine 1.2.1
ZF 1.9.6
====
End System Information
====
====
Directory Structure
====
mysite/
application/
configs/
application.ini
schema.yml
modules/
default/
models/
scripts/
rebuild_models.php
bootstrap.php
data/
doctrine/
fixtures/
migrations/
sql/
library/
Zend/
ZendX/
Doctrine/
Doctrine.php
public/
.htaccess
index.php
====
End Directory Structure
====
===
Application Bootstrap (mysite/application/bootstrap.php)
===
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAppAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default',
'basePath' => dirname(__FILE__).'/modules/default',
));
$autoloader->addResourceTypes(array(
'controllerhelper' => array(
'namespace' => 'Controller_Helper',
'path' => 'controllers/helpers',
)));
return $autoloader;
}
protected function _initDoctrine()
{
$this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine','autoload'));
spl_autoload_register(array('Doctrine','modelsAutoload'));
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE,true);
$manager->setAttribute(
Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE
);
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES,true);
$dsn = $this->getOption('dsn');
$conn = Doctrine_Manager::connection($dsn, 'doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
return $conn;
}
}
===
End Application Bootstrap
===
===
Schema File
===
---
User:
columns:
id:
primary: true
autoincrement: true
type: integer(4)
username: string(255)
password: string(255)
relations:
Groups:
class: Group
refClass: UserGroup
foreignAlias: Users
Group:
tableName: groups
columns:
id:
primary: true
autoincrement: true
type: integer(4)
name: string(255)
UserGroup:
columns:
user_id: integer(4)
group_id: integer(4)
relations:
User:
onDelete: CASCADE
Group:
onDelete: CASCADE
===
End Schema File
===
===
rebuild_models.php
===
<?php
define('APPLICATION_PATH', 'D:\Web Server Root\Projects\mysite
\application');
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '\modules\default\models'),
realpath(APPLICATION_PATH . '/../library'),
)));
require_once('Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance();
require_once(APPLICATION_PATH . '/../library/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE);
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
$manager->setAttribute(Doctrine_Core::ATTR_EXPORT,
Doctrine_Core::EXPORT_ALL);
$manager->setCharset('utf8');
$manager->setCollate('utf8_unicode_ci');
$dsn = "mysql://mysite_user:[email protected]/mysite_db";
$conn = Doctrine_Manager::connection($dsn, 'doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
$config = array(
'data_fixtures_path' => APPLICATION_PATH.'/data/doctrine/fixtures',
'models_path' => APPLICATION_PATH.'/modules/default/models',
'migrations_path' => APPLICATION_PATH.'/data/doctrine/migrations',
'sql_path' => APPLICATION_PATH.'/data/doctrine/sql',
'yaml_schema_path' => APPLICATION_PATH.'/configs',
'generate_models_options' => array(
'pearStyle' => false,
'generateTableClasses' => true,
'generateBaseClasses' => true,
'classPrefixFiles' => false,
'baseClassPrefix' => 'Base',
'classPrefix' => 'Default_Model_',
'baseClassesDirectory' => null,
)
);
Doctrine_Core::setModelsDirectory($config['models_path']);
$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);
===
end rebuild_models.php
===
--
View this message in context:
http://n4.nabble.com/Configuring-Doctrine-CLI-1-2-1-to-properly-generate-ZF-1-9-6-compatible-models-tp961254p961254.html
Sent from the Zend Framework mailing list archive at Nabble.com.