0

I'm trying to update my phpunit version, however it doesn't seem to be working with the regular composer install.

My composer.json file is as follows:

{
    "require": {
        ...
    },
    "require-dev": {
        "phpunit/phpunit": "4.*",
        "phpunit/php-invoker": "^1.1",
        "phpunit/dbunit": "^2.0"
    }
}

And running both composer install and update as php composer.phar install and php composer.phar update (I don't have composer installed globally which might be the issue?) I get

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update

When I check to see the phpunit version, I get

$ phpunit --version
PHPUnit 3.7.28 by Sebastian Bergmann.

My PHP version is 5.6 which does seem to rule out the solution from this very similar issue.

My best guess is that there is a global version of phpunit installed and overriding my local one. But I haven't been able to find any guidance as to how to fix this without making too many changes to the rest of the global environment.

4
  • Yes, you've got a global phpunit installed, which you'd have to upgrade outside of your repo/Composer. The one installed by Composer lives at vendor/bin/phpunit (which you can use directly, if you like). Commented Mar 13, 2017 at 14:01
  • @ceejayoz So is there a way to run the local version of phpunit instead? Thanks in advance. Commented Mar 13, 2017 at 14:08
  • Sure, just use vendor/bin/phpunit instead of phpunit in your commands (presuming you're already cded into the repository). vendor/bin/phpunit --version etc. Commented Mar 13, 2017 at 14:09
  • 1
    Got it. I ran into a small permissions issue for /vendor/phpunit/phpunit/phpunit where I couldn't execute from vendor/bin/phpunit, but after adjusting those permissions, I can run it fine now. Thanks! Commented Mar 13, 2017 at 14:30

1 Answer 1

5

The command by itself phpunit will search in your shell's path for a PHPUnit executable. A composer install will place it into the composer bin dir, which is vendor/bin by default. You can execute the script directly with ./vendor/bin/phpunit, or allow composer to execute it for you, resolving the proper path for your project with composer exec phpunit

Sign up to request clarification or add additional context in comments.

1 Comment

composer exec phpunit Script phpunit handling the __exec_command event returned with error code 255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.