18

We have a Centos 6.3 machine running PHP 5.3.3. I accidentally uninstalled PHPUNIT. I am not able to reinstall it again. The newer versions do not work with PHP 5.3.3. Unfortunately, I cannot update my PHP version (company is stuck). How do I fix it?

I tried:

$ wget https://phar.phpunit.de/phpunit.phar
$ chmod +x phpunit.phar
$ sudo mv phpunit.phar /usr/local/bin/phpunit
$ phpunit --version

as suggested and it is not working.

2
  • Looking at phar.phpunit.de, you should be able to specify the version, e.g. wget https://phar.phpunit.de/phpunit-3.7.10.phar
    – kero
    Commented Feb 18, 2016 at 22:17
  • Thanks kingkero, your suggestion worked. Please post this as an answer, I will accept it.
    – ssk
    Commented Feb 18, 2016 at 22:19

2 Answers 2

20

So I simply took a look at https://phar.phpunit.de and as you can see there, you can specify the version number you want to install, eg.

$ wget https://phar.phpunit.de/phpunit-4.8.9.phar

However, I'd recommend using Composer where you can specify version numbers as well (described in the doc)

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

Using Composer brings many advantages. One of them is that you can make sure that the same version of a library is used by everyone working on the project (without having to share all the vendor files!)

4
  • 1
    And English documentation for older versions of PHPUnit may be found at: phpunit.de/manual/4.8/en. Replace 4.8 with the version you'd like to learn more about.
    – bishop
    Commented Feb 8, 2019 at 17:31
  • it not working for me! can someone help? Commented Feb 16, 2022 at 7:43
  • @SunilPrajapati What does "not working" mean? Which method have you tried and what errors do you get? It might make sense to create a new question, referencing this one and explaining in detail what you tried and where it failed.
    – kero
    Commented Feb 21, 2022 at 9:29
  • 1
    @kero Sorry, i had latest version installed with homebrew, that's why it wasnt working. its fine now. Commented Feb 24, 2022 at 12:51
7

kero's answer is great, however I want to add an example of using phpunit in one deprecated script in our company

{
  "require": {
    "phpunit/phpunit": "*",
    "php": ">=5.3.17"
  }
}

It install latest supported version (4.8.35 in this case) for PHP 5.3.17 after composer update and can't be used something like this:

./vendor/bin/phpunit SomeTest.php

1
  • Thanks ! That helped me A LOT !
    – Orange Lux
    Commented Mar 28, 2017 at 15:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.