I copied the project from windows to ubuntu. It seems to have connected everything as it should, but when I start it, I get an error in the title (# 16) and a clean screen. What kind of error is this and why doesn’t it jump out? Here is the error in the logs.

[Sat Jul 09 22:10:57.555546 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP Notice: Trying to get property of non-object in /var/www/film.lc/common/widgets/header/Menus.php on line 22 [Sat Jul 09 22:10:57.555562 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP Stack trace: [Sat Jul 09 22:10:57.555569 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 1. yii\\base\\ErrorHandler->handleFatalError() /var/www/film.lc/vendor/yiisoft/yii2/base/ErrorHandler.php:0 [Sat Jul 09 22:10:57.555574 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 2. yii\\web\\ErrorHandler->renderException() /var/www/film.lc/vendor/yiisoft/yii2/base/ErrorHandler.php:244 [Sat Jul 09 22:10:57.555578 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 3. yii\\base\\Module->runAction() /var/www/film.lc/vendor/yiisoft/yii2/web/ErrorHandler.php:93 [Sat Jul 09 22:10:57.555582 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 4. yii\\base\\Controller->runAction() /var/www/film.lc/vendor/yiisoft/yii2/base/Module.php:454 [Sat Jul 09 22:10:57.555586 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 5. yii\\base\\Action->runWithParams() /var/www/film.lc/vendor/yiisoft/yii2/base/Controller.php:154 [Sat Jul 09 22:10:57.555590 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 6. call_user_func_array:{/var/www/film.lc/vendor/yiisoft/yii2/base/Action.php:92}() /var/www/film.lc/vendor/yiisoft/yii2/base/Action.php:92 [Sat Jul 09 22:10:57.555594 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 7. yii\\web\\ErrorAction->run() /var/www/film.lc/vendor/yiisoft/yii2/base/Action.php:92 [Sat Jul 09 22:10:57.555598 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 8. yii\\base\\Controller->render() /var/www/film.lc/vendor/yiisoft/yii2/web/ErrorAction.php:108 [Sat Jul 09 22:10:57.555602 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 9. yii\\base\\Controller->renderContent() /var/www/film.lc/vendor/yiisoft/yii2/base/Controller.php:378 [Sat Jul 09 22:10:57.555606 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 10. yii\\base\\View->renderFile() /var/www/film.lc/vendor/yiisoft/yii2/base/Controller.php:392 [Sat Jul 09 22:10:57.555609 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 11. yii\\base\\View->renderPhpFile() /var/www/film.lc/vendor/yiisoft/yii2/base/View.php:247 [Sat Jul 09 22:10:57.555613 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 12. require() /var/www/film.lc/vendor/yiisoft/yii2/base/View.php:325 [Sat Jul 09 22:10:57.555617 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 13. yii\\base\\Widget::widget() /var/www/film.lc/frontend/views/layouts/main.php:27 [Sat Jul 09 22:10:57.555630 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP 14. common\\widgets\\header\\Menus->run() /var/www/film.lc/vendor/yiisoft/yii2/base/Widget.php:98 [Sat Jul 09 22:10:57.556813 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP Parse error: syntax error, unexpected '}', expecting end of file in /var/www/film.lc/common/widgets/header/views/html.php on line 162 [Sat Jul 09 22:10:57.556843 2016] [:error] [pid 14918] [client 127.0.0.1:53566] PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0 

here is menus

 <?php namespace common\widgets\header; use frontend\widget\comment\Comment; use Yii; use yii\base\Widget; use common\models\Category; use common\models\Image; use common\models\Commet; use common\models\Sites; use yii\helpers\ArrayHelper; class Menus extends Widget{ public $menu; public function init() { parent::init(); } public function run() { $comments=Commet::find()->orderBy(['created_at'=> SORT_DESC])->limit(20)->all(); $cat=Category::find()->select(['id','name_category','slug_category'])->where('tags=0')->all(); $img=Image::find()->select(['path','name'])->where('logo=1')->one(); if(Yii::$app->user->identity->id != null) { $avatar = Image::find()->select(['path', 'name'])->where(['id_user' => Yii::$app->user->identity->id])->one(); }else{ $avatar= false; } $sites=Sites::findOne(1); $categorypages=Category::findOne($sites->cat_for_footer); return $this->render('html',[ 'cat' => $cat, 'img' => $img, //'avatar' => $avatar, 'comments' => $comments, 'categorypages' => $categorypages ]); } } 

and I do not understand what is the error

  • This description does not give anything ... Is there really no description? If you turn on the display of errors - is there anything else? The screen can then be attached and so on .... what is written in the logs? what is written in the console in the Network (what is the status there?) and so on - Alexey Shimansky
  • @ Alexey Shimansky yes, PHP Notice curses it for the sake of it: Trying to get it on this code that I swear on the question - Sergalas 6:51 pm
  • @Sergalas problem in the string Yii :: $ app-> user-> identity-> id, either user or identity not initialized. - cheops

1 answer 1

I don’t know why this is displayed by the error Yii::$app->user->identity->i d in this line if(Yii::$app->user->identity->id != null) { replaced by if(!Yii::$app->user->isGuest) {

  • one
    Your answer contains the same line — both before and after the replacement. - aleksandr barakin
  • @alexanderbarakin yes sorry corrected - Sergalas