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
phpcd - PHP Completion Daemon Plugin for Vim/NeoVim
Introduction
PHPCD (PHP Completion Daemon) is another PHP completion engine for Vim/NeoVim.
PHPCD is based on phpcomplete.vim but is faster and smarter.
While phpcomplete.vim uses the tags file to fetch the context info, PHPCD uses PHP's Reflection mechanism to fetch the context info, and this is why PHPCD is faster. All the phpcomplete VimL code related the tags file has been droped and reimplemented.
PHPCD consists of two parts. On part is written in VimL (mainly based on phpcomplete.vim), and the other in PHP. The communication between the VimL part and the PHP part relies on NeoVim's MsgPack-RPC mechanism. This is why NeoVim is needed. Both NeoVim and Vim 8.0+ are supported now. Thanks to NeoVims's MsgPack-RPC and Vim's Channel/Job mechanism.
Feature
Fast, Lightweight, Powerful, Smart
Correct restriction of static or standard methods based on context (show only static methods with :: and only standard with ->)
Real support for self::, static::, parent:: and $this-> with the aforementioned context restriction
Better class detection
Recognize /* @var $yourvar YourClass */、 /* @var YourClass $yourvar */ type mark comments
Recognize $instance = new Class; class instantiations
Recognize (new Class)-> class instantiations
Recognize $date = DateTime::createFromFormat(...) built-in class return types
Recognize both parameter type hinting and return hinting in function prototypes
Recognize types in @param lines in function docblocks
Recognize types in @return lines in function docblocks
Recognize $instance = Class::foo()->bar(); method call chain return type
Recognize array of objects via docblock like $foo[42]-> or for variables created in foreach
Recognize property type by assignment in __construct
Recognize property type by setter
Namespace autocompletion (you first need to do composer dump-autoload -o)
Displays docblock info in the preview for methods and properties
Support built-in class support with constants, methods and properties
Enhanced jump-to-definition on ctrl+]
Installation & Usage
System requirement
PHP 5.6+ The master branch only support php7. If you have to use php5, please use the php5 branch.
First, in the project directory, run composer install to install all the dependent packages and generate the autoload file.
The composer is not required any more. However, if you want to let phpcd work with your project, you must to make a autoload file for your project.
If you use composer, composer will make the vendor/autoload.php. phpcd will use vendor/autoload.php automatically.
If your project does not use composer but have a path/to/autoload_file.php, you need to create a .phpcd.vim file in your project root path, and let it reads
And phpcd will use the g:phpcd_autoload_path to load your class.
The default PHP command used to run PHP parts of daemon is simply php. You may override it by assigning g:phpcd_php_cli_executable another value in your vimrc, for example:
let g:phpcd_php_cli_executable = 'php7.0'
Use Ctrl+xCtrl+o to complete and use ctrl+] to go to the definition.
If you use neosnippet, you may like to set g:phpcd_disable_modifier to 0.
Good luck :)
About
phpcd - A Intelligent/Smart PHP Complete Daemon Plugin for Vim/NeoVim