Question: phpunit or vendor/bin/phpunit?
Potherca opened this issue · 4 comments
I was wondering what the rational was behind using phpunit
instead of vendor/bin/phpunit
.
This seems weird to me, especially since PHPUnit is included as a Composer development dependency but may not be available globally.
Hi, this is closely related to #7.
I think the only reason that we simply say phpunit
at this point is because many people have vendor/bin
in their PATH, so phpunit
works anyway. However, it's a valid point. I'm personally not a fan of having PHPUnit installed globally.
Just a side note:
"scripts": {
"test": "vendor/bin/phpunit"
}
Would not work for Windows users.
But it is not necessary anyway.
The Composer docs state:
Note: Composer's bin-dir is pushed on top of the PATH so that binaries of dependencies are easily accessible as CLI commands when writing scripts.
https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands
I've tested it on my Windows machine. Due to legacy support I still have PHPUnit 3.7.38 installed globally, but in the project I've tested this with I have a locked version 4.6.6.
Calling composer test
shows me that the locked version and thus the one in veondor/bin/
is executed:
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.
So I guess that answers this question 😼
Thanks for the reply, composer test
seems to be the way forward. Question is indeed answered 😸
Dentro de la carpeta del proyecto.
En windows solo debes ejecutar el siguiente comando:
vendor\bin\phpunit
Saludos.