yii2调用不了内置的php,PHP致命错误 - yii \ base \ ErrorException在YII2中调用未定义的方法Yii :: app()...

public function actionIndex()

{

// renders the view file 'protected/views/site/index.php'

// using the default layout 'protected/views/layouts/main.php'

if (Yii::app ()->user->isGuest) {

$this->redirect ( Yii::app ()->createUrl ( 'site/login' ) );

} else {

// Export Scenario

$exportScenario = 'incoming';

$exportScenario2 = 'outgoing';

$exportScenario3 = 'missed';

// Default date

$date = null;

$fromDate = null;

$toDate = null;

//Model definitions

$model = new Logs ();

//get incoming calls

$incalls = $model->getInCalls();

// For filtering grid

$filtersForm = new GridForm ();

// Get filtered data

$filteredData = $filtersForm->filter ( $incalls );

$inDataProvider = new yii\data\ArrayDataProvider ( $filteredData, [ // Define pagination

'pagination' => [

'pageSize' => 10000

]

] );

//get outgoing calls

$outcalls = $model->getOutCalls();

// For filtering grid

$filtersForm = new GridForm ();

// Get filtered data

$filteredData = $filtersForm->filter ( $outcalls );

$outDataProvider = new CArrayDataProvider ( $filteredData, [ // Define pagination

'pagination' => [

'pageSize' => 10000

]

] );

//get missed calls

$missedcalls = $model->getMissedCalls();

// For filtering grid

$filtersForm = new GridForm ();

// Get filtered data

$filteredData = $filtersForm->filter ( $missedcalls );

$missedDataProvider = new CArrayDataProvider ( $filteredData, [ // Define pagination

'pagination' => [

'pageSize' => 10000

]

] );

// For Excel exporting and getting printable versions

if (isset ( $_GET ['export'] )) {

$exportHash = $_GET ['id'];

if ($_GET ['export'] == 'excel') {

// Exporting excel

Common::export ( null, 'get', $exportHash );

} else {

// Getting printable html

Common::export ( null, 'get', $exportHash, 'html' );

}

}

$this->render('index', [

'exportScenario' => $exportScenario,

'exportScenario2' => $exportScenario2,

'exportScenario3' => $exportScenario3,

'inDataProvider'=>$inDataProvider,

'outDataProvider'=>$outDataProvider,

'missedDataProvider'=>$missedDataProvider,

'filtersForm' => $filtersForm,

'date'=>$date,

'model'=>$model,

'incalls'=>$incalls

]);

}

}

我运行此网站http://localhost/master/web/index.php?r=site/index但出现错误 Call to undefined method Yii::app() . 我正在使用yii2基本应用程序 . 任何帮助,将不胜感激 .

上面的代码是sitecontroller.php的摘录,错误来自这一行

if(Yii :: app() - > user-> isGuest){$ this-> redirect(Yii :: app() - > createUrl('site / login')); }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值