我正在使用Zend_Application_Bootstrap_Bootstrap,但框架无法加载模型。
的index.php
define('ROOT_PATH', realpath(dirname(dirname(__FILE__))));
define('APP_PATH', realpath( ROOT_PATH . '/application'));
set_include_path(realpath(ROOT_PATH . '/library') . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Application.php';
$app = new Zend_Application('dev', APP_PATH . '/configs/application.ini');
$app->bootstrap()->run();
的application.ini
bootstrap = APP_PATH "/Bootstrap.php"
phpSettings.display_errors = on
phpSettings.display_startup_errors = on
phpSettings.error_reporting = E_ALL|E_STRICT
phpSettings.date.timezone = "Europe/London"
resources.frontController.controllerDirectory = APP_PATH "/controllers"
resources.frontController.throwExceptions = on
resources.view.encoding = "UTF-8"
resources.view.contentType = "text/html;charset=utf-8"
resources.view.doctype = "XHTML1_STRICT"
resources.layout.layoutPath = APP_PATH "/views/layouts"
resources.layout.layout = "layout"
resources.db.adapter = "Pdo_Mysql"
resources.db.params.host = "localhost"
resources.db.params.dbname = "foo"
resources.db.params.username = "user"
resources.db.params.password = "password"
resources.db.params.charset = "utf8"
bootstrap.php中:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}
文件夹树:
Myproject->
/application
/configs
/controllers
/models
/Mytest.php
/views
Bootstrap.php
/public
index.php
问题: 我试图在控制器中创建新的Mytest(),但我得到“找不到类......” 当我添加到bootstrap Zend_Loader :: loadClass('Mytest',APP_PATH。'/ models /')时,一切正常。
我的问题是,如何通过application.ini将Zend_Application_Bootstrap_Bootstrap设置为autoload models文件夹?
谢谢。
答案 0 :(得分:1)
默认情况下,模型类在ZF的“Application”命名空间中命名。 所以你的班级将被命名为'Application_Model_Mytest'
您可以通过将其添加到application.ini
来设置默认命名空间“Application”appnamespace = "Application"