4

Background: i am on a windows host and sshing into a vagrant LAMP setup (ubuntu 13.04).

I have installed phpunit with composer using the following line in my composer.json:

"require-dev": {
        "phpunit/phpunit": "3.7.*"
}

I have then run composer update which installed phpunit. I can now navigate to /vendor/bin and see phpunit binary.

However if i type phpunit from within that directory (or anywhere elese for that matter) I get the error "phpunit is not installed"

Any suggestions as to where I go next with this - there are so few steps involved in this setup I really cant see where I could have gone wrong

Rooneyl
  • 7,802
  • 6
  • 52
  • 81
SwiftD
  • 5,769
  • 6
  • 43
  • 67

3 Answers3

5

So I had this issue too, for me the fix was to change in my vagrant file:

config.vm.synced_folder "C:/dev/vm/share", "/var/www/", mount_options: ['dmode=777','fmode=666']

to

config.vm.synced_folder "C:/dev/vm/share", "/var/www/", mount_options: ['dmode=777','fmode=777']

There is a lot of advise saying 666 is permissive enough, but in my case it was not and as this is only a development machine the security implications are not too important.

jzahedieh
  • 1,570
  • 1
  • 15
  • 27
4

./phpunit from the bin directory.

It's just not in your path.

  • Dang I wish the downvoter would explain why the downvote. Here's a full illustration of the problem and the solution: https://dl.dropboxusercontent.com/u/20304987/terminal.html jerkwad ;) – Stop Slandering Monica Cellio Jul 31 '13 at 14:21
  • +1 I think you are (almost) right. When I follow your instruction I get a permission denied message (despite being the owner of the file) when I run it with sudo I get 'command not found'. Any suggestions? – SwiftD Aug 02 '13 at 14:28
  • `if [ -x "phpunit" ]; then echo "executable"; else echo "not executable"; fi` tests if it's executable. `ls -la` will also tell you who can execute the file, if anyone. `chmod a+x phpunit` makes it executable by everyone. That's all the bash help you get for a PHP question :) – Stop Slandering Monica Cellio Aug 05 '13 at 01:24
0

I created the script above:

#!/bin/bash
binary=$1
shift
dir=$PWD
for i in $( seq 5 )
do
 if [ -e "$dir/composer.json" ]
 then
  $dir/vendor/bin/$binary $@
 else
  echo "not found phpunit in $dir"
 fi 
  dir="$dir/.."
done

If you name it 'composer.exec', and put it n your path, you can call it:

composer.exec phpunit [phpunit-options]

And there is it! Calling phpunit or any other bin contained in vendor/bin.