Skip to content

Instantly share code, notes, and snippets.

@itsliamjones
Last active June 15, 2017 09:19
Show Gist options
  • Save itsliamjones/538fc21d8d259bc6bf5164c0c11b142f to your computer and use it in GitHub Desktop.
Save itsliamjones/538fc21d8d259bc6bf5164c0c11b142f to your computer and use it in GitHub Desktop.
Global installation of PHP tools with Composer

To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:

$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
$ composer global require phploc/phploc
$ composer global require phpmd/phpmd
$ composer global require squizlabs/php_codesniffer

This will install PHPUnit and all its dependencies into the ~/.composer/vendor/ directory and, most importantly, the phpunit CLI tools are installed into ~/.composer/vendor/bin/.

Simply add this directory to your PATH in your ~/.bash_profile (or ~/.bashrc) like this:

export PATH=~/.composer/vendor/bin:$PATH

and phpunit is now available on your command line.

To keep your tools up to date, you simply do this:

composer global update To remove a package, you edit ~/.composer/composer.json and then run composer global update.

Credit: Rob Allen Stored here for personal notes

Export documentation for PHP project: $ phpdoc -d "./src" -t "./docs/api" --template="responsive-twig"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment