New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimal PHP set up? #590
Comments
Have you tried these https://github.com/neoclide/coc.nvim/wiki/Language-servers#php ? I'm using this one https://www.npmjs.com/package/coc-phpls and it seems to work very well for most projects. Having some timeout issues, but I'm thinking this has something to do with permissions or something like that becuase I have vendor stuff living in a docker volume. |
@andersevenrud - cheers, those have helped, unfortunately it does not seem to play well with Laravel. I am learning the framework so it would be extremely helpful to have intelligent auto complete. Do you have any experience with that? |
I've noticed this as well. It seems that I never can get auto-completion deeper than one or two levels at most. Slim and Symfony seems to work a lot better, so there must be something in the dependency chain that breaks something. I also get a couple of timeouts every now and then. A couple of things of note is that type hinting in the sources is critical for things to work properly. You can also add phpdoc:
This is probably one of the reasons why it's a bit of a struggle on Laravel, because there's a lot of "magic methods" and such. |
Has anyone figured out how to properly handle *.blade.php files? I was using prettier for code formatting, but its doing a horrible job. Will coc-phpls format? |
@jonleopard I'm using https://github.com/jwalton512/vim-blade with https://github.com/alvan/vim-closetag
|
Just expanding on my previous comment
Using the same docblocks that phpStorm generates, autocompletion in models works pretty good. Example:
|
Is there an easy way to generate these blocks within vim? |
I found this while researching this subject https://github.com/barryvdh/laravel-ide-helper . Been a bit busy until today, so haven't tested it yet -- but it looks like it will do the job :) |
The ide-helper can probably be combined with https://github.com/noahfrederick/vim-laravel , but I don't really mind writing |
I just did and it adds the docblock for the Model Class just as advertised 🙌 |
One issue I had with using the php intelephense with coc was the it would autocomplete an extra $ for variables example: $message = "";
$hello = $mes<tab>
// gave me
$hello = $$message; I fixed this with the following autocommand in my init.nvim in case its helpful |
Use |
I'm using laravel-ide-helper and coc-phpls but it still complains about relationship methods (like $article->tags()) not existing. Any ideas? |
@codeclem Are you using docblocks on your class methods ? Edit: The |
Like this?
Still doesn't work. |
@codeclem Indeed. That should be enough. Does anything else work ? Have you tried to troubleshooting tips ? Might be some errors occurring on the back end. |
Seems to have started working now. Not sure why it wasn't before, thank you. |
Sorry.. it looks like specifically it's not working when using helpers. Like in this line: It complains about |
I see. The laravel-ide-helper package should generate documentation to make Edit: I actually have to do this in order for it to work as expected:
|
Hi,
I'm new to PHP and am trying to get my wonderful nvim setup that works with TS, JS & Go to work as well as for PHP.
Could someone share which LS they are using, and maybe some additional plugins,
.vimrc
config, orcoc.vim
config to get a better experience? Thanks.The text was updated successfully, but these errors were encountered: