Leighton Kuchel
Leighton Kuchel

Reputation: 357

Can't run PHPUnit as it says "PHPUnit requires PHP 5.6", but I have 4.2 installed

I've been stuck on this for around 4hrs now. I'm trying to run some tests on my Laravel 5 project. They worked a month or so ago when I ran them last, but I'm wanting to run them again. Just FYI, I'm using Vagrant.

Here's a snippet from my composer.json file.

"require": {
    "laravel/framework": "5.0.*",
    "illuminate/html": "^5.0",
    "doctrine/dbal": "~2.5",
    "maatwebsite/excel": "~2.0.0",
    "zizaco/entrust": "dev-laravel-5",
    "kalnoy/nestedset": "^3.0"
},
"require-dev": {
    "phpunit/phpunit": "4.2.*",
    "phpspec/phpspec": "~2.1"
},

But whenever I run phpunit through the terminal, it states

This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.

I've tried the below - all found via Google and Stack Overflow.

Entering in the below all return the same error message about PHP 5.6

For what it's worth, /vendor/phpunit/composer.json shows

"require": {
    "php": ">=5.3.3",
    ...
}
...
"extra": {
    "branch-alias": {
        "dev-master": "4.2.x-dev"
    }
},

Also, calling php -v shows "PHP 5.4.45 (cli) (built: Sep 4 2015 15:40:44)". phpinfo() shows the same thing.

Any ideas what's going on here?

Upvotes: 3

Views: 4380

Answers (1)

elixenide
elixenide

Reputation: 44833

You have more than one copy of phpunit on your system. Running this command in a terminal will tell you which one is in your path:

which phpunit

As your comments above confirmed, you weren't using the one in your project folder, so you'll need to start phpunit with

./vendor/phpunit/phpunit/phpunit [rest of command]

or create a symlink to that copy.

Upvotes: 1

Related Questions