Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 3.12 KB

README_en.md

File metadata and controls

74 lines (50 loc) · 3.12 KB

asciicast

Introduction

PHPCD (PHP Completion Daemon) is another vim omni complete engine for PHP.

PHPCD is based on phpcomplete.vim but is faster;

While phpcomplete.vim using the tag file to fetch the context info, PHPCD use the PHP's Reflection mechanism to fetch the context info, and this is why PHPCD is faster. All the phpcomplete VimL code related the tag 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 is rely on the NeoVim's MsgPack-RPC mechanism. This is why the NeoVim is needed.

Feature

  • Fast, Lightweight, Strong
  • 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 $instance = Class::foo()->bar(); method call chain return type use bar's @return docblocks
    • Recognize $date = DateTime::createFromFormat(...) built-in class return types
    • Recognize type hinting in function prototypes
    • Recognize types in @param lines in function docblocks
    • Recognize array of objects via docblock like $foo[42]-> or for variables created in foreach
  • 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

  1. PHP 5.3+
  2. socket Extension
  3. PCNTL Extension
  4. Msgpack 0.5.7+ Extension
  5. NeoVim
  6. Composer Project

Install PHPCD

We recommend you use Vim-Plug to mange your vim plugins.

With Vim-Plug installed, put the following lines in your vimrc,

Plug 'phpvim/phpcd.vim', { 'for': 'php' }
Plug 'vim-scripts/progressbar-widget' " used for showing the index progress

And then execute :PlugInstall in the command mode.

Enable PHPCD

Let PHPCD complete php,

autocmd FileType php setlocal omnifunc=phpcd#CompletePHP

Usage

First, run composer update to install all packages and generate the autoload file.

Then, use NeoVim to open a php file. You will see a progress bar several seconds later. When the bar finish, you could enjoy you PHP coding.

Use Ctrl+xCtrl+o to complete and use ctrl+] to go to the defination.

Good luck :)