How to install PHPUnit with WAMP?

前端 未结 5 2093
情深已故
情深已故 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:37

    Also check this out, may be useful http://www.mark-leong.com/installing-php-and-phpunit-on-windows-7/

    // adding required pear channels

    pear channel-update pear.php.net

    pear upgrade-all

    pear channel-discover pear.phpunit.de

    pear channel-discover components.ez.no

    pear channel-discover pear.symfony-project.com

    pear update-channels

    // performing install

    pear install --alldeps --force phpunit/PHPUnit

    If everything ok, check whether phpunit have been installed by putting in command line

    phpunit -v

    If you encountered any errors or interrupted installing

    pear clear-cache

    may be usefull in that case.

    0 讨论(0)
  • 2021-02-07 14:38

    1) download https://phar.phpunit.de/phpunit.phar 2) run it via php phpunit.phar

    Btw if that file ever goes away you can look at the original directions here: https://github.com/sebastianbergmann/phpunit

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-07 14:57

    I recommend using composer. It can be used per project, but also 'globally'.

    Make a folder on your C drive called 'globalpackages', then cd into it from the command line.

    run 'composer require phpunit/phpunit'

    once that finishes run 'composer install'

    once that finishes you can check the contents of C:\globalpackages\vendor\phpunit' and should see two phpunit files, one of them a bat.

    Add C:\globalpackages\vendor\phpunit to your system path and then you will be able to run phpuni from anywhere on your system.

    0 讨论(0)
  • 2021-02-07 15:04

    Try this blog : http://nishutayaltech.blogspot.com/2011/04/installing-phpunit-on-windows.html

    This setup is for Windows. Hope this will help you.

    0 讨论(0)
提交回复
热议问题