在vim中調(diào)試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
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
#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 擴(kuò)展.
2:vim 里面
:!php -l % 這個(gè)是檢查當(dāng)前php文件語法參數(shù)
:phpcs 這個(gè)就是code sniffer了
:phpmd ?這個(gè)是mess detector , 需要一個(gè)XML規(guī)則文件如果沒有設(shè)置
:phpcc ?這個(gè)顯示code coverage. 也需要一個(gè)XML規(guī)則文件如果沒有設(shè)置
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
#type phpcs
/usr/bin/phpcs
autorun = 1是自動(dòng)開啟 ,當(dāng)你保存的時(shí)候就會(huì)自動(dòng)運(yùn)行提示了
<?xml version="1.0"?><ruleset name="Sebastian" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> <description>Sebastian Bergmann's ruleset</description> <rule ref="rulesets/codesize.xml/CyclomaticComplexity" /> <rule ref="rulesets/codesize.xml/NPathComplexity" /> <rule ref="rulesets/codesize.xml/ExcessiveClassComplexity" /> <rule ref="rulesets/codesize.xml/ExcessiveClassLength" /> <rule ref="rulesets/codesize.xml/ExcessiveMethodLength" /> <rule ref="rulesets/codesize.xml/ExcessiveParameterList" /> <rule ref="rulesets/design.xml/EvalExpression" /> <rule ref="rulesets/design.xml/ExitExpression" /> <rule ref="rulesets/design.xml/GotoStatement" /> <rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" /> <rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" /> <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" /> <rule ref="rulesets/unusedcode.xml/UnusedPrivateField" /> <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" /></ruleset>
現(xiàn)在做下測(cè)試,打開vim 輸入 ?然后:w保存,提示錯(cuò)誤,說php不能關(guān)閉..看來語法要求很嚴(yán)格. 去掉?> 然后保存就沒錯(cuò)誤提示了.
<?php?>
具體的可以在shell里面 -h 查看使用
參考網(wǎng)址
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/?相關(guān)xml聲明
http://joncairns.com/2012/05/using-vim-as-a-php-ide/#comment-133?phpqa的文章
https://github.com/joonty/vim-phpqa? ? ?還是phpqa的
PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)