Search code examples
phpyii2yii2-advanced-appyii2-basic-app

I have no error when I run project with xampp, but have these error online


I am beginner with Yii2,When I run my website by Xampp I don't have any errors, but after I uploaded it to a linux server I got this error:

Non-static method frontend\controllers\SiteController::actionCategories() should not be called statically, assuming $this from incompatible context

What is causing this?

 <?php
      $category_post = \frontend\controllers\SiteController::actionCategories($row['id']);
      echo ListView::widget([
           'dataProvider' => $category_post,
           'itemView' => 'news_title',
           'summary' => '',
           'pager' => [
                'options' => ['class' => 'row pagination '],
           ]
      ]);
 ?>

Solution

  • just use

    Yii::$app->controller->actionCategories($row['id']);
    

    instead of

    \frontend\controllers\SiteController::actionCategories($row['id']);