Yii2 PHPStorm Debug Environment Issue


(usamashakeel) #1

Hi Guys,

Error I am getting is :
PHP Fatal error: Uncaught Error: Class ‘yii\web\Controller’ not found in /Applications/MAMP/htdocs/yii-application/backend/controllers/SiteController.php:13
Stack trace:
#0 {main}
thrown in /Applications/MAMP/htdocs/yii-application/backend/controllers/SiteController.php on line 13

I am new to Yii, but I am trying to configure development environment for it. I have installed PHPStorm, and everything is working on web browser if I open through URLs in a browser.

I want to debug code through step by step debugging and for that I have installed Plugins, Yii2 Support, Yii2 Inspections, and Php Inspections.

I have tried giving Yii Root Path to

  • /Applications/MAMP/htdocs/yii-application/vendor/yiisoft
  • /Applications/MAMP/htdocs/yii-application/vendor/yiisoft/yii2

I must be missing some essential step, can you guys help ?


(Mehdi Achour) #2

Hi,

Did you install and configure xdebug for your PHP?
What does your Run/Debug configuration look like?

Here’s an interesting resource: https://medium.com/@uginpo/how-to-debug-a-yii2-project-with-xdebug-and-phpstorm-ide-112e6cf50768


(usamashakeel) #3

Hi Mehdi,
Thanks for taking time out to respond.

I think XDebug is properly configured, as I am able to debug simple php files other than Yii2 Projects.

Attached herewith is image of validation of configuration.


(Mehdi Achour) #4

Ok.

(Just to clear out the confusion: The Yii Root Path, Yii2 Support, Yii2 Inspections & PHP Inspections have nothing to do with xdebug & the problem you’re facing.)

The Debugger configuration seems ok. Now how did you configure your Debug configuration?

Here’s mine for my frontend:
49%20AM

And the configuration for the “Front” server being used


(usamashakeel) #5

I might be doing this incorrect, can you also show me your server configuration ?


(usamashakeel) #6

My error is mentioned above, that means, when it tries to load it is unable to identify this path


(Mehdi Achour) #7

Server is classic Apache with mod_php

Can you screenshot your configuration?


(usamashakeel) #8

So when I try to Debug Controller, it comes to this line. At this line it is unable to find yii\web\Controller.