我在以下位置添加了 PHPUnit 依赖项composer.json
:
"require": {
"php-ds/php-ds": "v1.2.0",
"phpunit/phpunit": "v7.5.16"
}
Run Code Online (Sandbox Code Playgroud)
并运行我已经php-ds
安装的composer update 。
这在供应商目录中安装了 PHPUnit,但是当我检查phpunit
命令行时,它说:
找不到phpunit命令
Ger*_*che 12
$ phpunit
当您在命令行(例如 bash)上运行时,系统将从bash 文档中查找phpunit
使用该变量:PATH
PATH The search path for commands. It is a colon-separated list of directories in which the shell\n looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the\n value of PATH indicates the current directory. A null directory name may appear as two adja\xe2\x80\x90\n cent colons, or as an initial or trailing colon. The default path is system-dependent, and\n is set by the administrator who installs bash. A common value is ``/usr/local/bin:\n /usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\'\'.\n
Run Code Online (Sandbox Code Playgroud)\n\n您可以使用绕过搜索PATH
通过使用绝对路径来绕过使用变量的搜索:
$ /absolute/path/to/vendor/bin/phpunit\n
Run Code Online (Sandbox Code Playgroud)\n\n或相对路径(停止字符(.
)表示当前目录):
$ ./vendor/bin/phpunit\n
Run Code Online (Sandbox Code Playgroud)\n\n您实际上省略了停止斜杠部分:$ vendor/bin/phpunit
。
为了避免键入路径,您可以使用 bash 别名(如果您使用的是 bash):
\n\n$ alias phpunit=\'./vendor/bin/phpunit\'\n
Run Code Online (Sandbox Code Playgroud)\n\n或者保存输入:
\n\n$ alias p=\'./vendor/bin/phpunit\'\n
Run Code Online (Sandbox Code Playgroud)\n\n请参阅如何创建永久 bash 别名有关别名的更多信息,
\n