DEV Community

Cover image for PHPUnit: How to Access My Installed Version of PHPUnit on xampp
Ikechukwu Vincent
Ikechukwu Vincent

Posted on • Updated on

PHPUnit: How to Access My Installed Version of PHPUnit on xampp

The inability to access or use your installed PHPUnit is a common error in PHPUnit especially if you are using XAMPP.

Assuming that in your computer when you run

composer require --dev phpunit/phpunit ^9.2 check the version via the command-line interface, you see version 3.7x, then this article is for you. Normally xampp comes with version 3.x.x of PHPUnit. That is what is overriding your installed version.
Bottom line is that if you are building a PHP application on xampp, the preconfigured older version of PHPUnit in xampp will override the newer one you install.

Here is how I resolved this same problem recently along with its associated error messages.

  1. Go to xampp/PHP/pear directory. There you will see two folders named PHPUnit and PHPUnit2. Delete both folders.
  2. Go to xampp/php folder you will see two files named PHPUnit and another phpunit.bat. Delete both files.
  3. Go to environment variable settings. Just type env in your system search bar and hit enter. You will see the panel on the image below. Click the button I circled in red.

Alt Text
4... Once you click the button you will see

Alt Text

Copy the path to your PHPUnit C:\xampp-main\htdocs\projecFolder\vendor\bin
Then click on the places highlighted in red and click “Edit”, click “new” on the panel that will pop up. Add the path you just copied.

5... Restart your command prompt or open another command prompt. Type PHPUnit –version, you will see your installed version.

That is it. Now you can move on with your adventure in PHP unit testing.

  • Ikechukwu Unegbu

Top comments (0)