pear useful commands + setup for pear / PHPCS / PHPUnit / PHPMD / PHPDocumentor /
pear clear-cache
pear update-channels
- Housekeeping
pear config-get php_dir
- Displays directory which should be included in php include_path for correct working of packages
pear list -a
- List installed packages by channel
php --ini
- Display current ini file used by cli (and therefore Perl)
php -r 'echo get_include_path()."\n";'
- Check include_path actually in use by php
TO REMOVE ALL (mac)
sudo rm -rf ~/pear
sudo rm /usr/local/php5-5.4.16-20130615-025727/bin/pear
sudo rm -rf ./usr/local/php5-5.4.16-20130615-025727/bin/pecl
INSTALL PEAR / PHPCS (mac)
//pear
CMD: cd ~
CMD: wget http://pear.php.net/go-pear.phar
CMD: php go-pear.phar
Add '/Users/iboddington/pear/bin' (or chosen install dir) to PATH
e.g. export PATH=/Users/iboddington/pear/bin:$PATH; in ~/.bash_profile
//phpcs with plusnet standard
CMD: pear install PHP_CodeSniffer
CMD: pear channel-discover pear.internal.plus.net
CMD: pear install plusnet/PlusnetCodingStandards
Add alias to use standard
e.g. alias phpcs="phpcs --standard=Plusnet"; in ~/.bash_profile
//PHPDocumentor
CMD: pear search PHPDocumentor
//PHPMD
CMD: pear channel-discover pear.pdepend.org
CMD: pear install pdepend/PHP_Depend
CMD: pear channel-discover pear.phpmd.org
CMD: pear install --alldeps phpmd/PHP_PMD
Add functions to use txt / html versions with all available rulesets
e.g.
function phpmdtxt() {
phpmd $1 text codesize,unusedcode,naming,controversial,design;
}
function phpmdhtml() {
phpmd $1 html codesize,unusedcode,naming,controversial,design > /Library/WebServer/Documents/sandbox/phpmd.html;
}
//PHPUnit
CMD: pear channel-discover pear.phpunit.de
CMD: pear install phpunit/PHPUnit-3.7.19
//May need
- pear uninstall phpunit/PHPUnit-x.x.x
- pear channel-discover pear.symfony.com
- pear install phpunit/PHPUnit-3.7.19 --alldeps
- pear install phpunit/DbUnit-1.3.1 (again if done already)
//DBUnit (for PHPUnit)
CMD: pear install phpunit/DbUnit-1.3.1
//VFS (for PHPUnit)
CMD: pear channel-discover pear.bovigo.org
CMD: pear install bovigo/vfsStream-beta
After the above the following commands will be available
pear <command>
pecl <command>
phpcs <file> //Run plusnet standards against given file
phpdoc <command>
phpmdtxt <file>
phpmdhtml <file>
phpunit <command>