DEV Community

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

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

ikechukwu profile image Ikechukwu ・1 min read

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

composer require --dev phpunit/phpunit ^9.2 check the version via the command-line interface and 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.

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


Editor guide