安装说明
虚拟机:VirtualBox
操作用户:root
系统环境:centos6.6 x64
安装方式:Phar安装
软件:phpmd.phar
软件下载目录:/root/opt
下载地址:http://static.phpmd.org/php/2.2.3/phpmd.phar
安装[root@vb002 opt]# wget http://static.phpmd.org/php/2.2.3/phpmd.phar
[root@vb002 opt]# chmod +x phpmd.phar
[root@vb002 opt]# mv phpmd.phar /usr/local/bin/phpmd
检查是否安装成功
[root@vb002 opt]# phpmd -V
Mandatory arguments:
1) A php source code filename or directory. Can be a comma-separated string
2) A report format
3) A ruleset filename or a comma-separated string of rulesetfilenames
Available formats: xml, text, html.
Available rulesets: cleancode, codesize, controversial, design, naming, unusedcode.
Optional arguments that may be put after the mandatory arguments:
--minimumpriority: rule priority threshold; rules with lower priority than this will not be used
--reportfile: send report output to a file; default to STDOUT
--suffixes: comma-separated string of valid source code filename extensions
--exclude: comma-separated string of patterns that are used to ignore directories
--strict: also report those nodes with a @SuppressWarnings annotation
如果看到这个证明安装成果啦。
在安装的时候经历了一个小插曲。phpmd需要bz2支持的。所以,如果没有安装或者没有开启bz2扩展就会报错。
由于本人的虚拟机安装了LNMP,默认并没有安装bz2的支持。可以通过phpinfo打印结果看出来,如图。
看到了吧。确实是不支持bz2的,那怎么办?
找到lnmp安装包,就是重新编译php使其支持bz2
[root@vb002 opt]# cd opt/lnmp1.2-full/src/php-5.4.41/ext/bz2
[root@vb002 opt]# /usr/local/php/bin/phpize
[root@vb002 opt]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@vb002 opt]# make && make install
vi /usr/local/php/etc/php.inc
添加extension=bz2.so
[root@vb002 opt]# lnmp restart
phpinfo,如果看到这个证明安装成果啦。
再运营一下phpmd -V是不是正常了呢
参考文献:
http://phpmd.org/
http://www.duo66.com/post-1906.html