[英]can't extend Class 'Zend_Controller_Action'
I'm new to zend framework and i've found a few material about my problem, but nothing works for me. 我是zend框架的新手,我已经找到了一些有关我的问题的材料,但对我而言没有任何用处。 I'm trying to commecto to an API through Zend so i decided to connect in the indexAction in the IndexController.php.
我试图通过Zend适应API,所以我决定在IndexController.php中的indexAction中进行连接。 I could paste the code but the server stops before the code i'm writing, at the third line of the script saying:
我可以粘贴代码,但是服务器在我编写的代码之前停止,在脚本的第三行说:
Debug Error: /imball-reagens/application/controllers/IndexController.php line 4 -
Class 'Zend_Controller_Action' not found
Si i downloaded the zend framework again and i placed the library folder of the download in the library folder of my project. 我再次下载了zend框架,并将下载的库文件夹放置在项目的库文件夹中。 The in the "index.php" file of my project i typed:
在我输入的项目的“ index.php”文件中:
require_once 'Zend/Controller/Action.php';
But the class is still not avalable. 但是该类仍然不可用。 And the require doesn't throw any exception.
并且require不会抛出任何异常。
What am I doing wrong? 我究竟做错了什么? How do you usually start a project in zend?
您通常如何在zend中启动项目? Don't you use IndexAction controller?
您不使用IndexAction控制器吗? Shouldn't the library be included by default in a zend project?
默认情况下,该库是否不应该包含在zend项目中? I started the project with zend studio and my index.php says:
我从zend studio开始了这个项目,我的index.php说:
if (function_exists('zend_deployment_library_path') && zend_deployment_library_path('Zend Framework 1')) {
$paths[] = zend_deployment_library_path('Zend Framework 1');
}
I'm using Zend Framework 1.12 Thanks for the help 我正在使用Zend Framework 1.12,谢谢您的帮助
Update:** The index.php
complete file: 更新:**
index.php
完整文件:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
$paths = array(realpath(APPLICATION_PATH . '/../library'));
if (function_exists('zend_deployment_library_path') && zend_deployment_library_path('Zend Framework 1')) {
$paths[] = zend_deployment_library_path('Zend Framework 1');
}
$paths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $paths));
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Controller/Action.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
Complete IndexController.php:
完整的
IndexController.php:
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
try {
$uri = "http://api.box.com/2.0/folders/0/items?";
$headers = array(
'Authorization: Bearer API_KEY',
);
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER=>$headers,
CURLOPT_SSL_VERIFYPEER=> false
//CURLOPT_USERPWD, "username:password"
),
);
$client = new Zend_Http_Client($uri, $config);
$response = $client->request();
$text= $response->getBody();
$view = new Zend_View();
$view->assign(text, $text);
} catch (Zend_Exception $e) {
echo "Message: " . $e->getMessage() . "\n";
// Other code to recover from the error
}
}
}
Not sure if your index.php code is correct. 不知道您的index.php代码是否正确。 Normally you'd need to have something like this:
通常,您需要具有以下内容:
// define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', __DIR__ . '/../application');
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV')
? getenv('APPLICATION_ENV') : 'production'));
// set include path
set_include_path(realpath(APPLICATION_PATH . '/../library')
. PATH_SEPARATOR . get_include_path());
require_once 'Zend/Application.php';
use, 采用,
require_once 'Zend/Application.php';
in your index.php instead of require_once 'Zend/Controller/Action.php';
在您的index.php中,而不是
require_once 'Zend/Controller/Action.php';
and try. 并尝试。
upadte UPADTE
make sure you are using zf1.12 library not the zf >2.. 确保您使用的是zf1.12库,而不是zf> 2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.