2017-05-08 39 views
1

我有PHPUnit版本5.3.2安裝通過全球作曲家,和版本5.7.19本地安裝在我的項目。我可以通過輸入phpunit和本地vendor/bin/phpunit運行全局PHPUnit。使用本地phpunit,如果安裝,否則回落到全球

有沒有辦法將PHPUnit配置爲默認運行本地安裝(如果存在),否則會回退到全局安裝,因此我不必每次都使用vendor/bin/phpunit

我想出了迄今爲止在項目目錄中創建一個bash腳本phpunit唯一的解決辦法:

#!/bin/bash 
vendor/bin/phpunit [email protected] 

但我必須鍵入./phpunit反正。

回答

1

看起來我並不那麼遠。所以我加了以下我的.bashrc

original_phpunit=$(which phpunit) 

phpunit() { 
    if [ -f vendor/bin/phpunit ]; then vendor/bin/phpunit [email protected] 
    else eval "'$original_phpunit' [email protected]" 
    fi 
} 

現在它按我的意思工作。希望有人會發現它有用!