search
Homephp教程php手册vim的symfony2开发环境配置

vim的symfony2开发环境配置

Jun 06, 2016 pm 08:12 PM
vimInstalldevelopenvironmentConfiguration

安装 最近在用Symfony2框架进行开发,正所谓工欲善其事必先利其器。为了提高开发效率,因此将vim配置为symfony的IDE。 我安装的是phpcomplete-extended-symfony这款插件 https://github.com/m2mdas/phpcomplete-extended-symfony 它有些依赖在文档中没写清楚

安装

最近在用Symfony2框架进行开发,正所谓工欲善其事必先利其器。为了提高开发效率,因此将vim配置为symfony的IDE。

我安装的是phpcomplete-extended-symfony这款插件 https://github.com/m2mdas/phpcomplete-extended-symfony

它有些依赖在文档中没写清楚,我也是折腾了好久才搞定的,于是做个笔记记录一下。

我总共安装了以下插件:

  • neocomplete.vim
  • vimproc.vim
  • unite.vim
  • phpcomplete.vim
  • phpcomplete-extended
  • phpcomplete-extended-symfony
  • vim-twig

我是使用的Vundle进行vim插件管理,因此在 .vimrc 配置中添加以下内容:

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'

然后再执行BundleInstall命令进行下载安装。

注意:vim-twig插件不是必需的,安装它只是为了编写twig模板时能够高亮。

使用

接下来说说使用流程。

1.vimproc需要编译
进行vimproc的安装目录,执行make命令进行编译。详细内容请阅读它的README文件。

2.安装ctags工具
由于当前的ctags工具不支持PHP的新特性,如命名空间、traits、interface,于是就需要给ctags打补丁。

下载打过补丁的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

编译安装:

$ tar xvjf ctags-better-php-parser.tar.bz2
$ ./configure
$ make
$ sudo make install

3.安装 composer.phar

$ curl -s https://getcomposer.org/installer | php

4.修改vim配置
在vim中添加如下配置:

au FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP
let g:phpcomplete_index_composer_command = 'composer.phar'

5.开始使用
进入Symfony项目的根目录,执行命令生成tags文件:

$ ctags -R --fields=+aimS --languages=php

然后使用vim打开该tags文件,根据提示创建索引文件。完成之后索引文件会创建在 .phpcomplete_extended 目录中。下次在项目的根目录下打开vim,如果提示 “Index Loaded.”则表示配置成功了。接下来编写代码时就会有补全提示以及use语句的自动补全了。

注意:在使用该插件时需要把自动切换目录功能给禁用掉,添加设置: set autochdir! 。否则会出现无法加载索引,从而补全不了。这个问题在文档中没说,我也是折腾了好久才发现的。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.