English 中文(简体)
Fatal error: Class Zend_Controller_Action not found
原标题:

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
最佳回答

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)

问题回答

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





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签