How to install PHPUnit with WAMP?

前端 未结 5 2092
情深已故
情深已故 2021-02-07 14:32

I\'m a newbie programmer and I have tried for an embarrassingly long time to get PHPUnit set up and working with WAMP. I have read the documentation and went through various sit

5条回答
  •  走了就别回头了
    2021-02-07 14:54

    For me this is the fastests and easiest way.

    1. Make sure you have wamp with WAMP with PHP 7 installed as phpunit requires PHP7 to work! or at least 6.2

    2. Go to folder wamp64\bin\php\php7.0.10 (wherever you installed your wamp - BEWARE last folder is name of PHP version you have so it might be different then above )

    We will be working in this folder during entire installation. So if I say edit file etc it means in this folder.

    1. Download newest version of phpunit from https://phpunit.de/

    At the time of writing this I get version phpunit 6.2 and php7.0.10 4. Copy downloaded file to wamp64\bin\php\php7.0.10 folder For me it's: phpunit-6.2.2.phar for you it might be different version.

    1. Now change name of the phpunit-6.2.2.phar to phpunit.phar

    2. Now make sure you have added your php to PATH in Environment Variables To do this on Windows 10 and Windows 8

    6a. In Search, search for and then select: System (Control Panel)

    6b. Click the Advanced system settings link.

    6c. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.

    6d. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Paste location of your PHP. For me it would be: D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10

    (if in PATH there was other command or path just add ";" at the end. For exmaple:

    %someOtherCommand%; D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)

    6e. Click OK. Close all remaining windows by clicking OK.

    1. In cmd (to run cmd go to search in Windows and type cmd.exe and click Enter) go to folder wamp64\bin\php\php7.0.10 (to go to folder type for example cd D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)

    2. now once you are in this folder run this command in cmd: echo @php "%~dp0phpunit.phar" %* > phpunit.cmd

    3. now run this command:

    phpunit

    you should get list of all commands available in phpunit

    now run this:

    phpunit --check-version

    you will get info what phpunit version you have and if you are using the newest version.

    1. if this doesn't work go to wamp64\bin\php\php7.0.10

    2. Edit file phpunit.bat

    3. Add this line:

      ""%PHPBIN%" "D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10\phpunit.phar" %*

    4. Repeat point 9.

    5. if it still doesn't work let me know.

提交回复
热议问题