Laravel-ide-helper: Phpstorm: "Multiple definitions exist for class ..." for Models

Created on 22 Oct 2014  路  10Comments  路  Source: barryvdh/laravel-ide-helper

I am using laravel 4.2 with laravel-ide-helper v1.11.3. I did generate the helper file for my database models and phpstorm also recognizes it, but whenever I use one of my Models it complains that it has "Multiple definitions exist for class ...".

Any idea how to resolve this without putting the helper information into the model files themselves?

Most helpful comment

I'm in the same boat. It stores the _ide_helper_models.php file in the base directory. I don't want to overwrite the model files in anyway as i'm not sure what other issues i might face. I'd prefer to keep it separate. But now it's just introducing more issues.

All 10 comments

I experienced a similar problem - though not about models - without the IDE Helper installed. I found the duplicates were coming from compiled.php.

My solution was to go to Settings -> File Types and add compiled.php to the list of ignored files and folders.

Perhaps this may help you too.

I've found it helpful to mark the entire storage directory as _excluded_.

Once you generate your model signature/helper file, just copy and paste the phpDoc from it to the actual model itself and then remove the created helper model. It's a no brainer - I think this issue really needs closing.

@shehi That is not really a solution due to the vast amount of manual work that would mean.

However, there is a flag (-W) that does exactly this for you as you generate the meta data: https://github.com/barryvdh/laravel-ide-helper#automatic-phpdocs-for-models

@knugen That might be true, but what you plan to do with file sitting inside the same namespace?! :D Its either exclusion or deletion.

@df-jablan @barryvdh Maybe I am missing something but, after running php artisan ide-helper:models, excluding the storage folder does not solve the problem....

I'm in the same boat. It stores the _ide_helper_models.php file in the base directory. I don't want to overwrite the model files in anyway as i'm not sure what other issues i might face. I'd prefer to keep it separate. But now it's just introducing more issues.

+1

Any solution?

php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config

config/ide-helper.php
image

This commit will also allow update of the meta file name...
https://github.com/barryvdh/laravel-ide-helper/commit/55c9bfc33b0e8fc35a8f7939f1d4afe5debf1eb3

image

should look like this...
image

_I tried this, for sake of a good test.... It then will ignore the ide_helper .. _

= hence making it useless. =

Personally I would rather have the "multiple definitions"
image
It seems to only pertain to facades anyway.

https://laracasts.com/discuss/channels/general-discussion/phpstorm-warning-multiple-definitions-exists-for-class?page=1
=> you just exclude those dirs in the IDE

But I also use https://github.com/dereuromark/cakephp-ide-helper/commit/fd094212e093bd15ae5f859c15d73f8f67e8d435 now to exclude those test files from all released tags on GitHub, thus when someone doesnt use dev-master but a real version tag he will not get those test_files and the problem resolves itself.
The assumption is: Projects not developing this vendor lib directly, do not use those test files that are only for test casing the vendor lib. No relevance for projects.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

half-evil picture half-evil  路  3Comments

kickthemooon picture kickthemooon  路  3Comments

quantumwebco picture quantumwebco  路  4Comments

beniaminorossini picture beniaminorossini  路  5Comments

neeravp picture neeravp  路  3Comments