在vim中調試php, 裝配php code_sniffer,php-md. phpqa.vim

來源:互聯網
上載者:User
在vim中調試php, 安裝php code_sniffer,php-md. phpqa.vim

1:安裝php code sniffer 和 php md

php code sniffer

a: centos系的

#yum install php-pear

#yum install ImageMagick-devel

#pear install PHP_CodeSniffer

#pear channel-discover pear.phpmd.org

#pear channel-discover pear.pdepend.org

#pear install --alldeps phpmd/PHP_PMD

修改php.ini檔案,加入extension=imagick.so


debian系的

#apt-get install php-pear

#apt-get install php5-imagick imagemagick

後面和上面centos的一樣,

只是不需要修改php.ini 加入imagick 擴充.


2:vim 裡面

:!php -l % 這個是檢查當前php檔案文法參數

:phpcs 這個就是code sniffer了

:phpmd 這個是mess detector , 需要一個XML規則檔案如果沒有設定

:phpcc 這個顯示code coverage. 也需要一個XML規則檔案如果沒有設定


3:安裝phpqa.vim

https://github.com/rainysia/vimrc/commits/master

去clone下來,放到$~.vim裡面, 注意是user下面的.vim

在.vimrc裡面加上

let g:phpqa_codesniffer_args = "--standard=Zend"let g:phpqa_codesniffer_cmd  = '/usr/bin/phpcs' let g:phpqa_codesniffer_autorun = 1        "  default =1 on savelet g:phpqa_messdetector_ruleset = ''let g:phpqa_messdetector_cmd = '/usr/bin/phpmd'let g:phpqa_messdetector_autorun = 0
其中cmd 這兩個是上面第一步安裝後 type出來的路徑,

#type phpcs

/usr/bin/phpcs

autorun = 1是自動開啟 ,當你儲存的時候就會自動運行提示了

  Sebastian Bergmann's ruleset                            

現在做下測試,開啟vim 輸入 然後:w儲存,提示錯誤,說php不能關閉..看來文法要求很嚴格. 去掉?> 然後儲存就沒錯誤提示了.





具體的可以在shell裡面 -h 查看使用

參考網址

http://phpmd.org/download/index.html 安裝phpmd

http://pear.php.net/package/PHP_CodeSniffer/redirected php code sniffer

http://blog.csdn.net/xinhaozheng/article/details/3324796 php code sniffer的使用

http://developer.51cto.com/art/201105/261292.htm php mess detor的使用

http://coreymaynard.com/blog/finding-what-stinks-and-cleaning-up-the-mess/ 相關xml聲明

http://joncairns.com/2012/05/using-vim-as-a-php-ide/#comment-133 phpqa的文章

https://github.com/joonty/vim-phpqa 還是phpqa的


  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.