Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii控制器找不到请求的视图_Php_Yii - Fatal编程技术网

Php Yii控制器找不到请求的视图

Php Yii控制器找不到请求的视图,php,yii,Php,Yii,我在呈现“错误”视图时遇到此错误 所有目录都是小写字母。我正在Linux机器上运行Yii Sample Code: class ApiController extends Api { private $api; private $placesapikey; public function __construct() { parent::__construct("Api"); $uri = explode('=', Yii::app()->request-

我在呈现“错误”视图时遇到此错误

所有目录都是小写字母。我正在Linux机器上运行Yii

Sample Code:

class ApiController extends Api
{
    private $api;
    private $placesapikey;

public function __construct()
{
    parent::__construct("Api");
    $uri = explode('=', Yii::app()->request->getQueryString());
    $this->api = end($uri);
    $this->placesapikey = "";

    if ($this->api != Yii::app()->params['apikey'] || $this->api == '')
    {
        $error['data']['title'] = "Un-Authorized Access";
        $error['data']['message'] = "You are not authorized to access or view this area";
        $this->render('error', $error);
        exit;
    }
}
尝试:


编写示例代码..那么,视图文件是否存在?还有,为什么要编写构造函数?这就是为什么!您还需要在目录结构中添加error.php视图和控制器的位置?@Jon这是我编写构造函数的原因;)同样的代码在我的本地服务器(MacOSXLion)上运行,但是当我将同样的代码推送到我的AWSEC2(Linux)实例时,它抛出上述错误。当然还有查看文件exists@bool.dev不,我没有试过,但现在我试过了,谢谢。但仍然好奇的是,当相同的代码在本地机器上运行时,为什么不在Linux机器上运行呢?你也可以发布你的答案,这样我就可以接受了。我真的不知道为什么会发生这种情况!!但是可能是由于一些htaccess规则,我猜,我也在亚马逊上部署我的东西,在mac上部署本地开发人员,所以如果我遇到这样的问题,我会给你回复。顺便说一句,你的控制器能找到其他视图吗?例如,在action methods中?我使用了官方Yii指南中的htaccess代码是的,它可以找到所有actionMethods,除了ApiController中的视图,一切都正常工作,你知道奇怪的是我有另一个控制器MainController.php,从中我调用了一个视图“index.php”在/protected/views/main/index.php中,比如$this->render('index');工作正常:DSure,如果我能找到什么,我会把它贴在这里
Sample Code:

class ApiController extends Api
{
    private $api;
    private $placesapikey;

public function __construct()
{
    parent::__construct("Api");
    $uri = explode('=', Yii::app()->request->getQueryString());
    $this->api = end($uri);
    $this->placesapikey = "";

    if ($this->api != Yii::app()->params['apikey'] || $this->api == '')
    {
        $error['data']['title'] = "Un-Authorized Access";
        $error['data']['message'] = "You are not authorized to access or view this area";
        $this->render('error', $error);
        exit;
    }
}
$this->render('/api/error', $error);