You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not familiar with Larvel - why is the helper file necessary - are the methods "magic" ? (also not sure why the methods have bodies, if this is a stub they would never be executed?)
As an experiment (with no idea if it will work) you might try including the helper file by setting:
in phpactor.yml (or phpactor.json) to the directory of the helper (instead of the php(storm stubs) (and then clearing the cache - phpactor cache:clear) this will break standard PHP function/class completion, but i it fixes the laravel issue, it would be simple to allow multiple files to be specified here.
Otherwise if you have a link to a recent open laravel project on Github, I can try and have a look and see what the problems are.
cc @einenlum will the above fix help, or do we need to support the Laravel autoloading mechanism (or do we need to support both stubs and the autoloading?)
TBH, I was so pissed off by Laravel and its aliases (man, I miss Sf so much), I took a week to remove aliases everywhere on every project I could find, with a search and replace. Took me a week because even PHPStorm is not good to replace these aliases with the real classes…
Now, this said, I can try on a previous version that have the aliases. Will try today.
Updated the cache, and it works!
It just does not work with a relative path. It seems %application_root% is transformed to the path of phpactor and not where the application lives (it's probably wanted?).
Edit: of course it's wanted cause phpactor can be run outside vim 🤦♂️
Maybe %project_root% if you want the root of the project?
... and now its working (after cache:clear)
Great news :) I will keep this ticket open in order to change the code to accept an array of locations for stubs (and maybe add a Laravel integration page in the docs
Reacted by Yann Rabiller, Anderson Danilo, Breno Brandão and Vitaly Kogogin
Now that phpactor uses an index, _ide_helper.php and _ide_helper_model.php seem to be picked up by the indexer. There is currently a looming issue with the @mixin tag not being supported yet, so technically this doesn't work, but it's a closer than I previously realized! The stubs path isn't necessary!
It seems the helper is "overriding" some vendor files in phpactor too. For example it doesn't see $request->user() as valid because the request it is using is from the _ide_helper.php file only. I think it's meant to "magically" use that along with the file from vendor.
The linked example above has all methods defined but mine has just magic ones, so I'm going to see if there is a way to just do all methods again like it used to.
I was pleasantly surprised to see that phpactor picked up on the _ide_helper.php and _ide_helper_models.php files out-of-the-box (using Neovim and the phpactor language server), however, there's two issues:
All of my Laravel classes and models are overridden, so jumping to definitions takes me straight to the _ide_helper* files.
I tried to circumvent this behaviour by using the @mixin tag, but it phpactor doesn't pick up on this.
Also, it doesn't look like the PhpStorm meta file (.phpstorm.meta.php) is picked up, is support for that on the roadmap? I saw some other issues mention it.
Running into this now as well. IDE helper generates a same class names with docs in a separate file. This files is being indexed but it loses the scope of the original class.
While mixin works, ideally this would not be required.
I might try to tackle this, but some pointers on where to start digging would be welcome :).
I'm not sure what needs to be done exactly. Would we want the analysis and docs to use the "helper" while goto definition / find references ignores the stub file? Without actually working on a Laravel project I'm not sure.
The helper only documents things that are not part of the model itself.
Now what happens (I think) is because the class Board is the same as my actual Board class, it ignores that one and only indexes the helper file.
This results in actually defined methods to be ignored.
It is perfectly fine for goto-definition to go to the helper file if it is a documented property/method/.., however, the original class should continue to work.
I would also like to know how people are using phpactor with laravel-ide-helper.
Currently, (1) if I use laravel-ide-helper, things like $request->user() are regarded as undefined methods because of the overriding behavior described above. (2) On the other hand, if I don't use laravel-ide-helper, I can't handle Laravel's (problematic) magic methods like User::create(...).
Both of the options aren't desirable. Did anyone find any workarounds?
in phpactor.yml (or phpactor.json) to the directory of the helper (instead of the php(storm stubs) (and then clearing the cache - phpactor cache:clear) this will break standard PHP function/class completion, but i it fixes the laravel issue, it would be simple to allow multiple files to be specified here.
is it already possible to specifiy multiple files here?
Well, the thing is that in Laravel there is an _ide_helper.php and _id_helper_models.php file, and both need to be loaded. And in addition I also want the plain PHP functions to work. So I think this is related. I tried the indexer.stub_paths option, but it seems like I cannot set files here, directories must be passed instead. Wouldn't it make sense to be able to pass files as well to this option?
However, putting both files in the same folder and add this folder to this indexer.stub_paths option works fine.
Using the laravel ide helper here with vim and some laravel projects.
Generating _ide_helper.php and _ide_helper_models.php into a folder (.ide_helpers) at the root of the project.
Adding to .phpactor.json the line "indexer.stub_paths": ["%project_root%\/.ide_helpers\/"]
The above resolve for me the facades (models mostly) functions to be known.
Now something I came across is the reflection getting only interfaces function definition instead of concrete class.
Example is for $this->app->isLocal() for instance does underline isLocal() not to be part of the interface (which is true).
but isLocal() can be found in _ide_helper.php
Coming to this issue since I upgrade my neovim version and config (my bad lol?) and I can't manage to get this to work (it was working previously). Could there be any issue with the new phpactor version?
Previously I only generated the ide helper in my project root, and phpactor would work out of the box (no config needed). But now, I tried all config options here, the indexer says it is loading them, and I still get issues reported for Model::query()->join for example.
I think somebody needs to investigate it, as I probably won't have time and as it doesn't affect my work directly there isn't much motivation for me to look into it. I'm happy to provide pointers in a discussion and help out.
Note that for Larvel you should change the indexer.include_patterns to includes the project source directories explicitly to avoid _ide_helper.php from being indexed (it should only be incldued as an "additive stub file").
Closing the issue for now, please re-open or comment if it is not fixed.
Do I need to limit what I add to indexer.include_patterns in this case? Or maybe I can add "%project_root%\/.ide_helpers\/" to indexer.exclude_patterns?
From the docs default value in indexer.include_patterns is ["\/**\/*.php","\/**\/*.phar"] which will include contents of my .ide_helpers directory, but my assumption was that since that dir is in stub_paths it should be excluded.
As noted in the docs, you probably do not want to override the stub paths as these are used for PHP core stubs and should be set by defualt to the jetbrains ide stubs - which you need.
Activity
[-][vim[/-][+][vim] Support for Laravel IDE Helper[/+]andersondanilo commentedon Aug 6, 2019
#611
dantleech commentedon Aug 6, 2019
I'm not familiar with Larvel - why is the helper file necessary - are the methods "magic" ? (also not sure why the methods have bodies, if this is a stub they would never be executed?)
As an experiment (with no idea if it will work) you might try including the helper file by setting:
in
phpactor.yml(orphpactor.json) to the directory of the helper (instead of the php(storm stubs) (and then clearing the cache -phpactor cache:clear) this will break standard PHP function/class completion, but i it fixes the laravel issue, it would be simple to allow multiple files to be specified here.Otherwise if you have a link to a recent open laravel project on Github, I can try and have a look and see what the problems are.
cc @einenlum will the above fix help, or do we need to support the Laravel autoloading mechanism (or do we need to support both stubs and the autoloading?)
einenlum commentedon Aug 7, 2019
TBH, I was so pissed off by Laravel and its aliases (man, I miss Sf so much), I took a week to remove aliases everywhere on every project I could find, with a search and replace. Took me a week because even PHPStorm is not good to replace these aliases with the real classes…
Now, this said, I can try on a previous version that have the aliases. Will try today.
einenlum commentedon Aug 7, 2019
@dantleech The file is generated through an artisan command:
artisan ide-helper:generate.It generates a
_ide_helper.phpfile in the root of the app.I added the stub dir in my phpactor configuration:
Given the following file:
When I try to jump on definition, I get:
Error from Phpactor: Unable to locate class "Config", Word "\Config" could not be resolved to a class.Edit: I forgot to clear the cache. Otherwise it would have said
_ide_helper.phpis not a directory.einenlum commentedon Aug 7, 2019
Oh! My bad @dantleech ! It works!
I moved the
_ide_helper.phpfile tovendor/ide-test. Then updated my config:Updated the cache, and it works!
It just does not work with a relative path. It seems
%application_root%is transformed to the path of phpactor and not where the application lives (it's probably wanted?).Edit: of course it's wanted cause phpactor can be run outside vim 🤦♂️
andersondanilo commentedon Aug 7, 2019
I tried to copy the file _ide_helper.php to ~/.vim/bundle/phpactor/vendor/jetbrains/phpstorm-stubs and now its working (after cache:clear)
dantleech commentedon Aug 7, 2019
Maybe
%project_root%if you want the root of the project?Great news :) I will keep this ticket open in order to change the code to accept an array of locations for stubs (and maybe add a Laravel integration page in the docs
FatBoyXPC commentedon Jan 15, 2021
Now that phpactor uses an index,
_ide_helper.phpand_ide_helper_model.phpseem to be picked up by the indexer. There is currently a looming issue with the@mixintag not being supported yet, so technically this doesn't work, but it's a closer than I previously realized! The stubs path isn't necessary!robclancy commentedon Jan 10, 2023
It seems the helper is "overriding" some vendor files in phpactor too. For example it doesn't see
$request->user()as valid because the request it is using is from the_ide_helper.phpfile only. I think it's meant to "magically" use that along with the file from vendor.The linked example above has all methods defined but mine has just magic ones, so I'm going to see if there is a way to just do all methods again like it used to.
calebdw commentedon Feb 10, 2023
I was pleasantly surprised to see that phpactor picked up on the
_ide_helper.phpand_ide_helper_models.phpfiles out-of-the-box (using Neovim and the phpactor language server), however, there's two issues:_ide_helper*files.@mixintag, but it phpactor doesn't pick up on this.Also, it doesn't look like the PhpStorm meta file (
.phpstorm.meta.php) is picked up, is support for that on the roadmap? I saw some other issues mention it.haringsrob commentedon Apr 16, 2023
Running into this now as well. IDE helper generates a same class names with docs in a separate file. This files is being indexed but it loses the scope of the original class.
While mixin works, ideally this would not be required.
I might try to tackle this, but some pointers on where to start digging would be welcome :).
dantleech commentedon Apr 16, 2023
I'm not sure what needs to be done exactly. Would we want the analysis and docs to use the "helper" while goto definition / find references ignores the stub file? Without actually working on a Laravel project I'm not sure.
haringsrob commentedon Apr 16, 2023
So ide helper generates for example _ide_models.php with something like this:
The helper only documents things that are not part of the model itself.
Now what happens (I think) is because the class Board is the same as my actual Board class, it ignores that one and only indexes the helper file.
This results in actually defined methods to be ignored.
It is perfectly fine for goto-definition to go to the helper file if it is a documented property/method/.., however, the original class should continue to work.
Sorry if this is not explained well.
9 remaining items
xtvk commentedon May 30, 2023
I would also like to know how people are using phpactor with laravel-ide-helper.
Currently, (1) if I use laravel-ide-helper, things like
$request->user()are regarded as undefined methods because of the overriding behavior described above. (2) On the other hand, if I don't use laravel-ide-helper, I can't handle Laravel's (problematic) magic methods likeUser::create(...).Both of the options aren't desirable. Did anyone find any workarounds?
danrot commentedon Jun 19, 2023
is it already possible to specifiy multiple files here?
dantleech commentedon Jun 19, 2023
No, but you should be able to do it here: https://phpactor.readthedocs.io/en/master/reference/configuration.html#indexer-stub-paths but I don't know if related to this issue?
danrot commentedon Jun 20, 2023
Well, the thing is that in Laravel there is an
_ide_helper.phpand_id_helper_models.phpfile, and both need to be loaded. And in addition I also want the plain PHP functions to work. So I think this is related. I tried theindexer.stub_pathsoption, but it seems like I cannot set files here, directories must be passed instead. Wouldn't it make sense to be able to pass files as well to this option?However, putting both files in the same folder and add this folder to this
indexer.stub_pathsoption works fine.einenlum commentedon Jan 11, 2024
I tried again and everything works out of the box with
_ide_helper.phpand_ide_helper_models.php. Not sure this issue still needs to stay open.calebdw commentedon Jan 12, 2024
@einenlum, it does not work out of the box, #2420 is still an issue.
einenlum commentedon Jan 12, 2024
Oh my bad 👍
dave2309 commentedon Aug 19, 2024
Hi all,
Using the laravel ide helper here with vim and some laravel projects.
Generating
_ide_helper.phpand_ide_helper_models.phpinto a folder (.ide_helpers) at the root of the project.Adding to
.phpactor.jsonthe line"indexer.stub_paths": ["%project_root%\/.ide_helpers\/"]The above resolve for me the facades (models mostly) functions to be known.
Now something I came across is the reflection getting only interfaces function definition instead of concrete class.
Example is for
$this->app->isLocal()for instance does underlineisLocal()not to be part of the interface (which is true).but
isLocal()can be found in_ide_helper.phpAny news on this front?
vivere-dally commentedon Nov 22, 2024
Coming to this issue since I upgrade my neovim version and config (my bad lol?) and I can't manage to get this to work (it was working previously). Could there be any issue with the new phpactor version?
Previously I only generated the ide helper in my project root, and phpactor would work out of the box (no config needed). But now, I tried all config options here, the indexer says it is loading them, and I still get issues reported for
Model::query()->joinfor example.Anyone know how to address this?
dantleech commentedon Nov 22, 2024
I think somebody needs to investigate it, as I probably won't have time and as it doesn't affect my work directly there isn't much motivation for me to look into it. I'm happy to provide pointers in a discussion and help out.
bilogic commentedon Nov 3, 2025
@mixinsolution Possible to handle Laravel Facades? vscode-phpactor#209dantleech commentedon Nov 29, 2025
This should finally be addresed by Additive Stubs.
Note that for Larvel you should change the
indexer.include_patternsto includes the project source directories explicitly to avoid_ide_helper.phpfrom being indexed (it should only be incldued as an "additive stub file").Closing the issue for now, please re-open or comment if it is not fixed.
nickkadutskyi commentedon Nov 29, 2025
@dantleech
I have files output from ide-helper in a subdirectory
.ide_helpersand then I add that directory as stab_paths like this:Do I need to limit what I add to
indexer.include_patternsin this case? Or maybe I can add"%project_root%\/.ide_helpers\/"toindexer.exclude_patterns?From the docs default value in
indexer.include_patternsis["\/**\/*.php","\/**\/*.phar"]which will include contents of my.ide_helpersdirectory, but my assumption was that since that dir is in stub_paths it should be excluded.dantleech commentedon Nov 30, 2025
As noted in the docs, you probably do not want to override the stub paths as these are used for PHP core stubs and should be set by defualt to the jetbrains ide stubs - which you need.
You need to use the "additive stubs".