我使用composer安装了PHPUnit, 每次运行时都需要调用 vendor/bin/phpunit
. 如何将 vendor/bin
添加到路径中,以便下次只需调用 phpunit
即可运行?
我使用composer安装了PHPUnit, 每次运行时都需要调用 vendor/bin/phpunit
. 如何将 vendor/bin
添加到路径中,以便下次只需调用 phpunit
即可运行?
你可以将当前目录添加到你的路径中。
对于Linux/Mac,在你的.bash_profile
中添加下面的内容,Windows也类似,在下面的行中修改并将其添加到你的PATH
中。
# include the current `vendor/bin` folder (Notice the `.` - This means current directory)
PATH="./vendor/bin:$PATH"
记得重新启动终端或者重新加载你的 bash_profile
文件。
现在你可以运行phpunit
命令,它会自动在./vendor/bin
中查找,如果存在则执行。
.bash_profile
文件? - user1995781phpunit
创建了一个快捷方式,而是所有位于 vendor/bin
目录中的二进制文件。 - skcin7alias p='vendor/bin/phpunit'
那么您只需要输入p
,它就会运行您的测试。
如果您正在使用Homestead - 您可以将此别名添加到aliases
文件中,这样它就会一直存在。
bin-dir
设置为./
。这会将二进制文件安装在您的根目录下。"config": {
"bin-dir": "./"
}
然后你只需要运行./phpunit
。我通常将bin-dir
设置为bin
,然后输入bin/phpunit
。对我来说太简短了。
如果你已经安装了phpunit,则需要删除vendor/phpunit
目录并重新运行composer install
,然后composer才会移动二进制文件。