Zend_Application_Bootstrap_Bootstrap 不加载模型

发布于 2024-11-10 18:48:07 字数 1892 浏览 2 评论 0原文

我正在使用 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() ,但我得到“在...中找不到类” 当我添加到引导 Zend_Loader::loadClass('Mytest', APP_PATH . '/models/') 时,一切正常。

我的问题是,如何通过 application.ini 设置 Zend_Application_Bootstrap_Bootstrap 以自动加载模型文件夹?

谢谢。

I am using Zend_Application_Bootstrap_Bootstrap, but framework can't load modeles.

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
{
}

Folder tree:

Myproject->
/application
   /configs
   /controllers
   /models
      /Mytest.php
   /views
   Bootstrap.php
/public
   index.php

Problem:
I trying to create new Mytest() in controller, but i get "class not found in..."
When I add to bootstrap Zend_Loader::loadClass('Mytest', APP_PATH . '/models/') everything works.

My questions is, how to setup Zend_Application_Bootstrap_Bootstrap via application.ini to autoload models folder ?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟花肆意 2024-11-17 18:48:08

默认情况下,模型类在 ZF 中的“应用程序”命名空间下命名。
因此您的类将被命名为“Application_Model_Mytest”

您可以通过将其添加到 application.ini 来设置默认命名空间“Application”

appnamespace = "Application"

Model classes are by default named in ZF under 'Application' namespace.
So your class would be named as 'Application_Model_Mytest'

You can set the default namespace 'Application' by adding this to the application.ini

appnamespace = "Application"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文