Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adrielzxdf's avatar

PHPStorm Laravel ide-helper

Hi,

I'm trying to port over to PHPStorm from Sublime to improve my workflow. However, I am having trouble getting the ide-helper to work in PHPStorm to remove all the undefined class and namespaces error.

I have installed installed barryvdh-laravel-ide-helper via composer:

"require-dev": {
    "barryvdh/laravel-ide-helper": "^2.1",
    "doctrine/dbal": "~2.3"
},

added the service provider in config/app.php

Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,

and generated the _ide_helper.php file with artisan:

php artisan clear-compiled
php artisan ide-helper:generate
php artisan optimize

However, I am still seeing all the errors in PHPStorm for the classes and namespaces. I'm not sure where to start checking to find out what went wrong.

I am using a new Laravel 5.1 installation, and PHPStorm 9.0.2 if this information is helpful. Thanks.

0 likes
8 replies
layer7's avatar
layer7
Best Answer
Level 24

Are your models stored in the 'app' folder? If not, you will have to publish the vendor config file and change the path.

php artisan vendor:publish

Also, you didn't generate the models:

php artisan ide-helper:models

As a side note, sometimes closing PHPStorm and re-opening it fixes the issue.

2 likes
adrielzxdf's avatar

Yes, the models are the in its original location, i.e. app/User.php. I have tried

php artisan vendor:publish

Sorry, I didn't mention that I have generated the models as well. The _ide_helpers_models.php file was generated, but I did get an error message while generating the models:

Exception: could not find driver
Could not analyze class App\User.

I have also restarted PHPStorm multiple times but to no avail.

adrielzxdf's avatar

Hi, the problem is solved. I had excluded the vendor file before to prevent it from being included in the search and forgotten about that. The ide helper file is working as expected now. Thanks!

jst's avatar

I think they meant the "vendor" directory. In PHPStorm you have to make sure that this folder isn't excluded from the source indexer (under the directories/module settings), which it unfortunately automatically is, when PHPStorm has the composer plugin installed. You can see excluded folders marked in red, while included source folders have a small blue dot in the lower left corner of the folder symbol. Only folders marked as "source" directories are scanned by the source indexer. So make sure that at least the "vendor/laravel/framework" folder is included.

luisgarciaalanis's avatar

Found the issue, ran the command on the homestead machine and it worked :)

2 likes
thomthom's avatar

Same as @luisgarciaalanis - when I ssh'd into the homestead machine it worked, but when I try locally I get Exception: could not find driver. Is this expected or is my setup wrong?


Edit: I just realized I had not enabled PDO in my local PHP installation: extension=php_pdo_mysql.dll And I also had to change DB_HOST in .env from localhost to 192.168.10.10 to avoid Exception: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. Now it's working fine.

1 like
maxity's avatar

@thomthom php_pdo_mysql.dll was a valuable hint, I never knew I'd have to enable it in addition to the regular mysql driver. It works now.

Please or to participate in this conversation.