Recently, the Symfony2 framework is used for installation and development. It is said that the tool must be used first to do a good job. To improve development efficiency, configure vim as the symfony IDE. I installed phpcomplete-extended-symfony, the plug-in github. comm2mdasphpcomplete-extended-symfony, which has some dependencies that are not clearly written in the documentation.
Recently, the Symfony2 framework is used for installation and development. It is said that the tool must be used first to do a good job. To improve development efficiency, configure vim as the symfony IDE. I installed phpcomplete-extended-symfony, the plug-in https://github.com/m2mdas/phpcomplete-extended-symfony, which is somewhat dependent on being not clearly written in the documentation.
Install
Recently, we are using the Symfony2 framework for development. It is the saying that we must first sharpen our tools to better do things. To improve development efficiency, configure vim as the symfony IDE.
I installed phpcomplete-extended-symfony plug-in https://github.com/m2mdas/phpcomplete-extended-symfony
Some of its dependencies were not clearly written in the document, and I had to make a note after a long time.
I have installed the following plug-ins in total:
- Neocomplete. vim
- Vimproc. vim
- Unite. vim
- Phpcomplete. vim
- Phpcomplete-extended
- Phpcomplete-extended-symfony
- Vim-twig
I am using Vundle For vim plug-in management, So Add the following content in. vimrc Configuration:
Bundle 'Shougo/neocomplete.vim'Bundle 'Shougo/vimproc.vim'Bundle 'Shougo/unite.vim'Bundle 'shawncplus/phpcomplete.vim'Bundle 'm2mdas/phpcomplete-extended'Bundle 'm2mdas/phpcomplete-extended-symfony'Bundle 'evidens/vim-twig'
Then run the BundleInstall command to download and install it.
Note: The vim-twig plug-in is not required. You only need to install it to highlight it when compiling the twig template.
Use
Next, let's talk about the procedure.
1. vimproc needs to be compiled
Run the make command to compile the installation directory of vimproc. For details, read its README file.
2. Install the ctags Tool
Because the current ctags tool does not support new PHP features, such as namespaces, traits, and interfaces, You need to patch ctags.
Download the source code of the patch ctags:
$ wget "https://github.com/shawncplus/phpcomplete.vim/blob/master/misc/ctags-better-php-parser.tar.bz2?raw=true" -O ctags-better-php-parser.tar.bz2
Compile and install:
$ tar xvjf ctags-better-php-parser.tar.bz2$ ./configure$ make$ sudo make install
3. Install composer. phar
$ curl -s https://getcomposer.org/installer | php
4. Modify vim configurations
Add the following configuration in vim:
au FileType php setlocal omnifunc=phpcomplete_extended#CompletePHPlet g:phpcomplete_index_composer_command = 'composer.phar'
5. Start Using
Go to the root directory of the Symfony project and run the command to generate the tags file:
$ ctags -R --fields=+aimS --languages=php
Use vim to open the tags file and create the index file as prompted. The index file is created in the. phpcomplete_extended directory. Run vim in the root directory of the project. If "Index Loaded." is displayed, the configuration is successful. The completion prompt and the automatic completion of the use statement will be displayed when you write the code.
Note:When using this plug-in, you need to disable the automatic directory switch function and add the setting: set autochdir! . Otherwise, indexes cannot be loaded and thus cannot be completed. This problem was not mentioned in the document and I found it only after a long time.
Original article address: configure the symfony2 development environment in vim. Thank you for sharing it with the original author.