composer global require drupal/coder
composer global show -P # should be equivalent to ~/.composer/vendor/drupal/coder
# Register Coder Standards: Drupal and DrupalPractice
composer global require drupal/coder:^8.2.12
composer global require dealerdirect/phpcodesniffer-composer-installer
# Review standards
phpcs -i
- Install & IDE instructions: https://www.drupal.org/node/1419988
- Command line usage: https://www.drupal.org/node/1587138
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar -h
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
php phpcbf.phar -h
curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit
Safer (project dependency):
In your project’s root directory use this command.
composer require --dev phpunit/phpunit ^6.0
This command adds PHPUnit to your project as a development dependency. This is the absolute best way to install PHPUnit. It is the best way because this way the version of PHPUnit does not change unless you change it. We specified ^6.0 as the version which means we’ll get all the updates to the 6.0 branch but not 6.1.
Harder (global dependency):
composer global require phpunit/phpunit ^6.0
On MacOS and Linux machines, this will install PHPUnit in ~/.composer/vendor/bin
. If you add this directory to your path, then from any project, you can execute PHPUnit. However, as noted above, if you ever upgrade your globally installed packages then you will have problems.
composer global update
Run that when there is a new version of PHPUnit, it will be installed, regardless of whether this will break your existing unit tests on one or more of your projects.