Laravel and autocomplete question/problem
I have a project which needs to be written with Laravel 3 framework. After I setup framework and the PHPStorm to my needs and start coding something odd happens (I've tried both 5.0.4 and 6.0 versions of PHPStorm on both Windows and Ubuntu). Whenever I type something like this
$password = Input
autocomplete kicks in and after "In" it suggests something like this
Input (\Symfony\Component\Console\Input\)
and after I hit Tab I get this
\Symfony\Component\Console\Input\Input::
let me just say that in autocomplete list there is no Laravel Input command...
If I try to use some other command that is specific to Laravel like View::
View (\Laravel\View) and after I hit Tab I get
\Laravel\View::
I do not use Symfony, I've disabled "Framework integration" I even tried to disable Plugins for framework integration but with no success.
I've tried to use "Invalidate cache and restart" on every attempt I make but with no success.
I have no idea left what to try so if you can help me with some ideas.
Please sign in to leave a comment.
Hi Vladimir,
If PhpStorm offers you such class in autocompletion, then most likely you do have such class somewhere (e.g. one of the PEAR packages perhaps .. or one of the Composer packages/dependencies that you may be using).
I suggest:
After you finish typing your \Symfony\Component\Console\Input\Input:: -- Ctrl+Click on last "Input" -- see where PhpStorm will take you -- file name and a path should give you the hints what this may be about.
P.S.
"Framework integration" definitely has nothing to do with it -- IDE does not come with any PHP framework.
Thx Andriy, I did what you suggested and found that autocomplete uses this file
<project name>/laravel/vendor/Symfony/Component/Console/Input/Input.php
Now I am puzzled even more since I don't know what to do now, since this file is inside one of the frameworks dir's.
I'm not a Laravel framework user (I just read about it in general; few reviews/simple comparisons -- this kind of stuff) ... but since it's inside <project root>/laravel/vendor/ .. I suspect that one of the bundles (or framework itself) uses it.
I suggest digging that way. Just go to that class and invoke "Find Usage" from context menu -- it should show you where it is used, so you may know if you have to keep it .. or if you can remove.
In any case:
1) You can remove any folder from your project -- just mark it as Excluded (via context menu in Project View .. or Settings | Directories) -- this folder will remain on your disk as is.. but will not be included in project indexes and therefore will not be participating/offered in any code completion.
2) If you need to exclude just a single file -- find it in Project View | right click | Mark as Plain text -- file still be there, but will be treated as plain text, which means so indexing/not participating in code completion.
Regarding "what that files is doing there" -- you should contact Laravel users (their forum/support) -- they should know much better how it can appear there (what bundle may use it etc)
OK, I use the Exclude command, now I only get \Laravel\Input:: so it is much much better then what I had before. Still not what I need but I can work with this.
Press Ctrl+Space (one more time if you have pressed it to bring this code completion popup in first place) -- it should show you all possible variants.
If you choose such another entry few times, IDE will prefer it over other variants.
Please describe what you expect to see instead.
Prefered way would be to have this
Input::
instead of
\Laravel\Input::
Problem with ctrl+space is that there is no other possible variant.
Well .. check available options at "Settings | Editor | Auto Import"
Invoking quick-fix menu (Alt+Enter) on \Laravel\Input:: should also provide some action to generate "use" statements manually (and, as a result, get rid of FQN).
If I go to
"Settings | Editor | Auto Import"
XML and "Show import popup" is ticked
PHP and "Automatically add use statement" is not ticked.
If I tick this PHP option when I type
Input
I get
Input (Laravel) and after hitting TAB the command is autocompleted and looks like
Input::
but if I try to type lets say get, this doesn't invoke anything (seems like it didn't get any list of command). When I complete typing Input::get(....) and try ALT + ENTER (it is important to do this ON Input:: part of Input::get()) then the use \Laravel\Input is generated at the top of the class and only after this do I get the autocompletion as I wanted.
And now the final question. Is there any way to put this use statements in one file and get autocompletion across the whole project or do I need to do this in every class that I write?
http://php.net/manual/en/language.namespaces.importing.php