I have added the PHPUnit dependency in the composer.json
:
"require": {
"php-ds/php-ds": "v1.2.0",
"phpunit/phpunit": "v7.5.16"
}
and ran composer update as I have php-ds
installed already.
This installed the PHPUnit in the vendor directory, but when I check phpunit
in command line it says:
phpunit command not found
When you run $ phpunit
on the command-line (e.g. bash), the system will look for phpunit
using the PATH
variable, from the bash docs:
PATH The search path for commands. It is a colon-separated list of directories in which the shell
looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the
value of PATH indicates the current directory. A null directory name may appear as two adja‐
cent colons, or as an initial or trailing colon. The default path is system-dependent, and
is set by the administrator who installs bash. A common value is ``/usr/local/bin:
/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''.
You can bypass search using the PATH
variable by using an absolute path:
$ /absolute/path/to/vendor/bin/phpunit
Or a relative path (the stop character (.
) means the current directory):
$ ./vendor/bin/phpunit
You actually omit the stop slash part: $ vendor/bin/phpunit
.
To avoid having to type the path you can use a bash alias (if you're using bash):
$ alias phpunit='./vendor/bin/phpunit'
Or to save typing:
$ alias p='./vendor/bin/phpunit'
See How do I create a permanent bash alias for more information on aliases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With