致命错误:类“Zend_Controller_Action”未找到

发布于 2024-08-14 05:51:33 字数 2107 浏览 7 评论 0原文

我找到了一些与这个问题密切相关的答案,但我仍然无法解决它。 我相信人们会说我的包含路径有些不正确,但我已经尝试了所有我能找到的解决方案,但都无济于事。

这是错误:

Fatal error: Class 'Zend_Controller_Action' not found in /Users/*me*/Sites/*site*/application/controllers/IndexController.php on line 3

这是包含语句:

$newIncludePath = array();
$newIncludePath[] = '.';
$newIncludePath[] = 'include';
$newIncludePath[] = get_include_path();
$newIncludePath[] = '../library';
$newIncludePath[] = '../application/classes/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/controllers';
$newIncludePath = implode(PATH_SEPARATOR, $newIncludePath);
set_include_path($newIncludePath);

require_once 'Zend/Controller/Front.php';
require_once 'Zend/Loader.php';

Zend_Loader::registerAutoload();

我已经在键盘上敲击了几个小时,搜索论坛。我是 zend 和 php 的新手。这件事让我头疼不已。我已明确将控制器添加到路径中。我不知道我在忽略什么。

顺便说一句,出于隐私原因,网站的名称已被编辑。

我永远感激这个决议。

mjs-edit:

我注意到我的包含内容有点不稳定。所以这里是一个重做:

$newIncludePath = array();
$newIncludePath[] = '.';
$newIncludePath[] = get_include_path();
$newIncludePath[] = '../library';
$newIncludePath[] = '../application/classes/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/library/';
$newIncludePath = implode(PATH_SEPARATOR, $newIncludePath);
set_include_path($newIncludePath);

var_dump 的输出:

string(148) "../application/controllers:.:.:/Applications/MAMP/bin/php5/lib/php:../library:../application/classes/:../application/models/:../application/library/"

我注意到 Zend/Controller/Action 存在于 ../library 下。所以,我不明白为什么应用程序找不到它。

如果我从 PHPDebug 运行 IndexController,它会返回

string(170) ".:/Users/me/Sites/site:/Applications/Zend/Zend Studio - 7.1.0/plugins/org.zend.php.framework.resource_7.1.0.v20091101-1523/resources/ZendFramework-1/library/" 
Fatal error: Class 'Zend_Controller_Action' not found in /Users/me/Sites/site/application/controllers/IndexController.php on line 5

I've found some answers that are closely related to this problem, but I still can't get it resolved.
I believe folks are saying that something is not correct with my include path, but I've tried all resolutions I could find to no avail.

Here's the error:

Fatal error: Class 'Zend_Controller_Action' not found in /Users/*me*/Sites/*site*/application/controllers/IndexController.php on line 3

Here's the include statements:

$newIncludePath = array();
$newIncludePath[] = '.';
$newIncludePath[] = 'include';
$newIncludePath[] = get_include_path();
$newIncludePath[] = '../library';
$newIncludePath[] = '../application/classes/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/controllers';
$newIncludePath = implode(PATH_SEPARATOR, $newIncludePath);
set_include_path($newIncludePath);

require_once 'Zend/Controller/Front.php';
require_once 'Zend/Loader.php';

Zend_Loader::registerAutoload();

I have been banging my head on the keyboard for hours scouring the forums. I'm new to zend and php. This stuff has given me a royal headache. I've explicitly added controllers into the path. I have no idea what I am overlooking.

btw, the me and site are redacted names for privacy reasons.

I am eternally grateful for a resolution.

mjs-edit:

I noticed my includes were a bit wonky. So here's a do-over:

$newIncludePath = array();
$newIncludePath[] = '.';
$newIncludePath[] = get_include_path();
$newIncludePath[] = '../library';
$newIncludePath[] = '../application/classes/';
$newIncludePath[] = '../application/models/';
$newIncludePath[] = '../application/library/';
$newIncludePath = implode(PATH_SEPARATOR, $newIncludePath);
set_include_path($newIncludePath);

The output of var_dump:

string(148) "../application/controllers:.:.:/Applications/MAMP/bin/php5/lib/php:../library:../application/classes/:../application/models/:../application/library/"

I noticed that Zend/Controller/Action exists under ../library. So, I don't understand why the app can't find it.

If I run IndexController from PHPDebug, it returns

string(170) ".:/Users/me/Sites/site:/Applications/Zend/Zend Studio - 7.1.0/plugins/org.zend.php.framework.resource_7.1.0.v20091101-1523/resources/ZendFramework-1/library/" 
Fatal error: Class 'Zend_Controller_Action' not found in /Users/me/Sites/site/application/controllers/IndexController.php on line 5

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

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

发布评论

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

评论(2

堇色安年 2024-08-21 05:51:33

Zend_Appilcation 自动加载器的默认行为是获取类名

Zend_Controller_Action

并将其转换为路径

Zend/Controller/Action.php

,然后尝试包含/需要加载该类所需的文件。

因此,您可能会遇到两个不同的问题

  1. 您的 PHP 包含路径未指向默认的 Zend 库文件夹,并且尝试包含 Zend/Controller/Action.php 失败。< /p>

  2. 自动加载器未正确注册

因此,在 IndexController.php 文件中,在类声明上方的全局命名空间区域中添加以下内容

var_dump(get_include_path());

:将输出您的包含路径值。检查包含路径中的每个单独路径,并确保将 Zend/Controller/Action.php 附加到其中之一解析为 Action.php 文件。如果没有,请采取措施确保存在允许这种情况发生的路径。

(上面假设您使用的是 Zend_Application,它是 Zend 自己的应用程序框架,基于他们自己的 Zend Framework。如果您独立使用这些组件,可能会出现进一步的复杂情况)

The default behavior of a Zend_Appilcation autoloader is to take the class name

Zend_Controller_Action

and convert it into a path

Zend/Controller/Action.php

and then attempt to include/require the needed file to load the class.

So, you could have two different things going wrong

  1. Your PHP include path isn't pointing to the default Zend library folder, and attempts to include Zend/Controller/Action.php are failing.

  2. The autoloader isn't registered correctly

So, in your IndexController.php file, add the following in the global namespace area above the class declaration

var_dump(get_include_path());

This will output your include path value. Check each individual path in your include path, and ensure that appending Zend/Controller/Action.php to one of them resolves to the Action.php file. If it doesn't, take steps to ensure that a path IS there that allows this to happen.

(the above assumes you're using a Zend_Application, which Zend's own application framework based on their own Zend Framework. If you're using the components stand-alone there could be further complications)

庆幸我还是我 2024-08-21 05:51:33

您的包含路径相对于应用程序根目录,但文件正在不同的级别(即应用程序/控制器)加载。因此,所有包含路径现在看起来都像 application/controllers/../library,这是不正确的。

我将通过在包含路径中使用绝对路径来解决此问题。例如,尝试将 ../library 更改为 Users/me/Sites/site/library

Your include paths are relative to the application root but the file is being loaded at a different level (ie. application/controllers). So, all include paths now look like application/controllers/../library which is incorrect.

I would fix this by using absolute paths in my include path. For example, try changing ../library to Users/me/Sites/site/library

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