开发者

Zend_Application_Bootstrap_Bootstrap doesn't load models

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-&g开发者_开发问答t;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.


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"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜