php – Yii Controller找不到请求的视图

前端之家收集整理的这篇文章主要介绍了php – Yii Controller找不到请求的视图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在渲染“错误”视图时遇到此错误
ApiController cannot find the requested view "error".

所有目录都是小写字母.我在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;
    }
}
尝试:
$this->render('/api/error',$error);

猜你在找的PHP相关文章