脚本宝典收集整理的这篇文章主要介绍了php – MVC Zend Framework中的类自动加载不起作用,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我把它上传到服务器上,自动加载我的课有问题.
当我想在indexcontroller中从我的类创建对象时,我收到错误消息:
$this->view->bottomCache = new Application_Model_Cache($this->cacheTime,'bottomCache');
我得到这个错误的消息:
Fatal error: Class 'Application_Model_Cache' not found in ........./IndexController.PHP on line 19
在我的本地主机上,我使用的是Zend Server CE,它可以运行.
拜托,你能给我一些建议,我会检查一下,知道它为什么不起作用?
解决了:
类的名字的第一个字母必须是大写的,Cache.PHP
EDIT2:
文件夹模型与模型
正如你在这个example中看到的那样
// application/models/GuestBook.PHP class Application_Model_Guestbook {
EDIT1:
我在http://framework.zend.com/manual/en/learning.quickstart.create-project.html使用了教程,所以我使用了文件结构.
quickstart |-- application | |-- Bootstrap.PHP | |-- configs | | `-- application.ini | |-- controllers | | |-- ErrorController.PHP | | `-- IndexController.PHP | |-- models | | |-- cache.PHP | | `-- DBTable | | `-- Downloaded.PHP | `-- views | |-- helPErs | `-- scripts | |-- error | | `-- error.phtML | `-- index | `-- index.phtml |-- library |-- public | |-- .htaccess | `-- index.PHP
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { PRotected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Application_','basePath' => dirname(__FILE__),));; $autoloader->addResourceType('model','model/','Model'); return $autoloader; } protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_TRANSITIONAL'); } }
的application.ini
[production] PHPSettings.display_startup_errors = 0 PHPSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.PHP" bootstrap.class = "Bootstrap" appnamespace = "Application" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 0 resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" PHPSettings.date.timezone = "Europe/London" resources.db.adapter = PDO_MysqL resources.db.params.host = localhost resources.db.params.username = ***** resources.db.params.password = **** resources.db.params.dbname = ***** resources.db.params.charset = "utf8" resources.db.params.names = "utf8" resources.view.doctype = "XHTML1_TRANSITIONAL" [staging : production] [testing : production] PHPSettings.display_startup_errors = 1 PHPSettings.display_errors = 1 [development : production] PHPSettings.display_startup_errors = 1 PHPSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1
以上是脚本宝典为你收集整理的php – MVC Zend Framework中的类自动加载不起作用全部内容,希望文章能够帮你解决php – MVC Zend Framework中的类自动加载不起作用所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。