Zend Autoloader 无法在实际站点上运行
有问题! 我正在使用 Zend Quickstart 应用程序作为(刚刚开始哈哈)开发的基础。 我的本地计算机 (WinXP) 上有 PHP/MySQL 服务器 所以那里一切正常。 但后来我尝试将我的网站上传到远程服务器。这就是我得到的:
Fatal error: Class 'Default_Model_Post' not found in /home/mysite/application/controllers/IndexController.php on line 13
第 13 行:
$post = new Default_Model_Post();
Default_Model_Post 类位于 application/models/post.php 在我的家庭服务器上,它是由 zend 应用程序找到的!
我检查过.htaccess - 有SetEnv APPLICATION_ENV生产线 这是我的 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"
autoloaderNamespaces[] = "Mysite_"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "mysite_ib"
resources.db.params.password = "my passwd here"
resources.db.params.dbname = "mysite_ib"
resources.db.isDefaultTableAdapter = true
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
这是 Bootstrap.php:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default',
'basePath' => dirname(__FILE__),
));
//print_r( Zend_Loader_Autoloader::getAutoloaders()); exit; //tried to get some info here lol
return $autoloader;
}
}
已经检查了我能想象到的一切!它可以在我的开发机器上运行,但在真实服务器上 - 它不能! 在 Google、Zend 文档和 stackoverflow 上进行了搜索,但总是不完全是我的问题(或者修复没有帮助)。 即使在真实服务器上,Mysite_ 命名空间中的类也可以正常工作。 实时服务器上的站点是我的开发站点的完整副本(压缩 -> 上传 -> 使用 zend lib 解压缩等) 请说出如何解决这个问题,或者至少如何调试它......我确信有一些该死的服务器选项我忘记了更改。 伙计们,我真的很依赖你们的帮助:(我的梦想项目毁了。抱歉英语不好。
having a problem!
I'm using Zend Quickstart application as basement for (just started lol) development.
I have PHP/MySQL server on my local machine (WinXP)
So everything works fine there.
But then I tried to upload my site to remote server. And this is what I get:
Fatal error: Class 'Default_Model_Post' not found in /home/mysite/application/controllers/IndexController.php on line 13
Line 13:
$post = new Default_Model_Post();
Default_Model_Post class is located at application/models/post.php
And on my home server it is found by zend app!
I have checked .htaccess - there is SetEnv APPLICATION_ENV production line
Here is my 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"
autoloaderNamespaces[] = "Mysite_"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "mysite_ib"
resources.db.params.password = "my passwd here"
resources.db.params.dbname = "mysite_ib"
resources.db.isDefaultTableAdapter = true
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Here is Bootstrap.php:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default',
'basePath' => dirname(__FILE__),
));
//print_r( Zend_Loader_Autoloader::getAutoloaders()); exit; //tried to get some info here lol
return $autoloader;
}
}
Have checked everything I can imagine! It works on my dev machine but on real server - it does not!
Have searched all over Google, Zend docs and stackoverflow but there's always not exactly my problem (or that fixes do not help).
Also classes in Mysite_ namespace work fine even on real server.
Site on the live server is total copy of my dev site (zipped -> uploaded -> unzipped with zend lib and so on)
Please say how to fix this or at least how to debug it... I'm sure there's some god damned server option that I have forgot to change.
Guys I really rely on your help :( project of my dream is in ruins. Sorry for poor English.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的帖子里的一切看起来都很正常。我唯一能想到的一件事是确保文件夹“models”的名称在您的服务器上拼写为小写。
您的开发机器是 Windows,因此这些细节可能在 Windows 上无关紧要,但在 Unix 上确实很重要。
Every thing looks normal in your post. the only one thing i could think of is make sure the name of the folder "models" is spelled lower case on your server.
You development machine is Windows, so these details may no matter on it but they do matter on Unix.
您的文件名应为
Post.php
(大写“P”)。正如 Atef 提到的,Windows 文件系统不区分大小写,因此对
application/models/Post.php
的请求将解析为您的文件。在 *nix 系统上,请求将失败,因为文件系统区分大小写。
Your file name should be
Post.php
(capital "P").As Atef mentioned, Windows file systems are case insensitive so a request for
application/models/Post.php
will resolve to your file.On a *nix system, the request will fail as the file system is case sensitive.