开发者

Doctrine Load Module Exception

I'm new to doctrine. I created an bootstrap file like the following one:

require_once(dirname(__FILE__)."/../conf/general.php");
require_once(dirname(__FILE__).'/Doctrine/lib/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));

$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL); 
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true); #for accessor  overriding
$manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true); #in order to be able to use the XTable classes
$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING,    Doctrine_Core::MODEL_LOADING_CONSERVATIVE); #to conservatively load files
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL); 

$dsn = "mysql:dbname=".DBNAME.";host=".DBHOST;
$dbh = new PDO( $dsn, DBUSERNAME, DBPASS );
$conn = Doctrine_Manager::connection( $dbh ); 
Doctrine_Core::loadModels('doc_models'); #In order to be able to work with models

php bootstrap.php
command works just as expected. But I have a file X.php under directory Y and i require bootstrap.php file in X.php ;but when i ran the X.php in the directory Y like
 php X.php
I got the following exception:

Doctrine_Exception: You must pass a valid path to a directory containing Doctrine models in /path_to_directory_of_bootstrap_file/Doctrine/lib/Doctrine/Core.php on line 635

Now, how can i fix this issue?

BTW开发者_StackOverflow中文版, when i put X.php and bootstrap.php in the same directory it works as expected. I also tried to require with absolute paths but this didn't solve my problem. I'm testing on Ubuntu 9.10 and installed doctrine from pear. Doctrine version is 1.2.0.


Did you try using absolute paths while requiring? Realpath can help you create those paths.


I think this error gets triggered when doctrine is expecting some model directories to exist. The error also occurs if you try to generate SQL from a schema.yml BEFORE you have built the model classes. When the model classes get built they create a bunch of directories and it's these that i think you are missing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜