How to setup VIM for php development?

1

I have been trying a lot (but not smartly) to figure out setting up VIM, ctags, omnicomple for PHP development.

On Googling I found this file. But have no clue how to use it.

What have I done until now? Here it is:

  1. I am on Fedora 17 64-bit OS
  2. Logged in as root Found my VIM version to be VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 8 2012 15:05:51)
  3. Followed the install details as here http://www.vim.org/scripts/script.php?script_id=3171

install details Place in $HOME/.vim/autoload/phpcomplete.vim and enable the php ftplugin

What else I am missing? How do I start using omnicomplete. (this is the first time I am using omnicomplete)

Why didn't I try IDE's?

I have a single core machine running LAMP stack. Didn't wanted to slow down everything and hence sticking to command line environment.

Ashwin kumar

Posted 2012-06-27T03:14:40.210

Reputation: 111

Hello Ashwin, There is the link related to your question for the best VIM customization. There are many usefulness of VIM for Php development. http://bit.ly/2Hvhe5f

– Elsner Technologies – 2019-05-22T09:00:19.597

Not directly related, but it may improve VIM... You can install a different color scheme, one that is more (or less) subtle, depending on what you need or like. http://cocopon.me/app/vim-color-gallery/ and http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own/

– SPRBRN – 2014-04-08T11:53:55.050

Answers

1

Vim already does PHP completion. The file in question is only an improvement over the default function. Anyway, to make it really useful you'll need a tags file that you generate with exuberant-ctags.

Read :help ins-completion, specifically the part on "omni completion", and :help ft-php-omni.

And you missed an important step: google "vim php ide" (without the quotes).

romainl

Posted 2012-06-27T03:14:40.210

Reputation: 19 227

0

Look at my VIM config: https://github.com/exu/vim-dotfiles

  • I'm using PIV (PHP Integration For VIM) + CTags (exuberant-ctags)

For tag generation I use command below:

ctags-exuberant -f tags \
    -h ".php" -R \
    --PHP-kinds=cfiv \
    --totals=yes \
    --tag-relative=yes \
    --PHP-kinds=cfiv \
    --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \
    --regex-PHP='/interface\s+([^ ]+)/\1/i/' \
    --exclude="*.js" \
    --exclude=".svn" \
    --exclude=".git"

UltiSnips as snippets for code generation (most powerfull snippets for VIM)

Look at my .vimrc, there are some PHP related things too.

Jacek Wysocki

Posted 2012-06-27T03:14:40.210

Reputation: 113

0

to generate tags for ctags, you'll need exuberant-ctags.

Pseudo steps to follow:

1) install exuberant-ctags on machine
2) issue ctags command in command line (what @jacek wrote)
3) in vim, normal mode, type:

:set tags=<tags location>

4) You can now use Ctrl-] like commands to view function definitions.

TagBar can be used to show function & variable names of local buffers: Github tagbar

To save typing step (4) every time vim starts, I have the following in my vimrc to do php specific setups:

autocmd FileType php call SetPHPOptions()
function! SetPHPOptions()
    setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab makeprg=php-xdebug\ %
    :call tagbar#autoopen(0)
    :set tags=~/.vim/php.tags
endfunction

snowbound

Posted 2012-06-27T03:14:40.210

Reputation: 416