Viewed   78 times

How to install phpunit?

I read documentation, but have an error:

>pear upgrade PEAR
Nothing to upgrade

>pear config-set auto_discover 1
config-set succeeded

>pear install
No releases available for package ""
install failed

How can I fix this error?



Old answer (2014): It's said that phpunit will not be available via PEAR since December 2014.
So it's easy to install it using composer:

composer global require "phpunit/phpunit=4.1.*"

Update 2019: it should be installed as a local (for your project) development package:

 composer require --dev phpunit/phpunit ^8

Update 2020: it should be installed as a local (for your project) development package: composer require --dev phpunit/phpunit ^9.3

Monday, December 12, 2022

After a lot of research, I've managed to find my own answers to this question.

In its most basic form, the answer is: What version of PHP you should install comes down what webserver you are running.

Here's a deeper explanation of the terms used in picking a version of PHP based on what I learned:

VC6 vs VC9

Firstly, different versions of Apache for Windows are compiled with different compilers. For example, the versions on are designed to be compiled using Microsoft Visual C++ 6, also known as VC6. This compiler is very popular, but also very old. (It dates back to 1998.)

There are different versions of Apache made for different compilers. For example, the versions available for download from are designed to be compiled with the popular and more much recent compiler, Microsoft Visual C++ 9 from 2008. Also known as VC9.

(Note: These two compilers are the two most popular options. So while it's possible to have a VC7, VC8, etc. compiled version of Apache, it's unlikely that you'll come across them.)

The use of this more recent compiler (VC9) is important because the latest versions of PHP are only being distributed in VC9 form (although older versions are still available for VC6).

On top of that, according to ApacheLounge there are numerous improvements when using a version of Apache compiled with VC9, "in areas like Performance, MemoryManagement and Stability".

If that wasn't enough, the developers of PHP made the following statement on their site:

Windows users: please mind that we do no longer provide builds created with Visual Studio C++ 6 (VC6). It is impossible to maintain a high quality and safe build of PHP for Windows using this unmaintained compiler.

We recommend the VC9 Apache builds as provided by ApacheLounge.

All PHP users should note that the PHP 5.2 series is NOT supported anymore. All users are strongly encouraged to upgrade to PHP 5.3.6.

In all, this is an extremely compelling argument to use VC9 versions of Apache and PHP, if you ask me.

So if you're using a version of Apache from the official Apache site, it will be compiled with VC6, and as such, you should use the older version of PHP for that compiler. If you're using a version of Apache compiled with VC9, like the one available on, you can use the latest version of PHP (for VC9).

For me, running a local development environment, it would be preferable to have the latest version of PHP, so a VC9 version of Apache is required, so I can use the VC9 version of PHP.

Thread Safe vs Non Thread Safe

Once again this comes down to your webserver. By default Apache is installed on Windows as Module, but it can be changed to run as FastCGI. There's plenty of differences between the two, but essentially FastCGI is more modern, faster, more robust, and more resource hungry. For someone running a local development environment, FastCGI might be overkill, but apparently lots of hosting companies run as FastCGI for the reasons I've stated, so there are good arguments for doing so in a development environment.

If you're running Apache (or IIS) as FastCGI (or CGI) then you want the Non Thread Safe version of PHP. If you're running Apache as default (as a Module), then you'll want the more traditional Thread Safe version.

Please note: This all only applies to Windows users.

I'm not going to bother with FastCGI (unless someone convinces me otherwise), so for me, I want the VC9 Thread Safe version of PHP.

And that's it.

Further reading:

  • Official statement regarding PHP and VC6
  • Difference between PHP thread safe and non thread safe binaries
  • FastCGI at Wikipedia
  • FastCGI for IIS
  • Visual C++ at Wikipedia
  • Compile your own PHP (explanation of VC6/VC9)
Sunday, October 23, 2022

I checked the PHPUnit folder, it was still there?

That might be because of sub-components (Extensions, Framework). However you must not be concerned about that.

To install the latest version, do the following two commands:

> pear config-set auto_discover 1
config-set succeeded

> pear upgrade

This will take some time, and will update all that is currently installed. As you have some extensions already available and the latest version of PHPUnit might require those, so update them to prevent failure in the next command:

> pear install

This should now install it:

Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.0.0)
downloading PHPUnit-3.6.7.tgz ...
Starting to download PHPUnit-3.6.7.tgz (118,349 bytes)
..........................done: 118,349 bytes
install ok: channel://

Troubleshooting PEAR

As you reported in comments, this did not work out. Probably pear is in a state that it does not know where top and bottom is. Time to force. First, clear the cache:

> pear clear-cache
reading directory C:...Temppearcache
0 cache entries cleared

Then force channel updates:

> pear channel-update -f
Updating channel ""
Update of Channel "" succeeded

> pear channel-update -f
Updating channel ""
Update of Channel "" succeeded

Then force the phpunit install:

> pear install -a -f phpunit/PHPUnit
Wednesday, October 12, 2022

Python 2.7.9+ and 3.4+

Good news! Python 3.4 (released March 2014) and Python 2.7.9 (released December 2014) ship with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Node.js, Haskell, Perl, Go—almost every other contemporary language with a majority open-source community. Thank you, Python.

If you do find that pip is not available when using Python 3.4+ or Python 2.7.9+, simply execute e.g.:

py -3 -m ensurepip

Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this in the question Does Python have a package/module management system?.

And, alas for everyone using Python 2.7.8 or earlier (a sizable portion of the community). There's no plan to ship Pip to you. Manual instructions follow.

Python 2 ? 2.7.8 and Python 3 ? 3.3

Flying in the face of its 'batteries included' motto, Python ships without a package manager. To make matters worse, Pip was—until recently—ironically difficult to install.

Official instructions


Download, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:


You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).

This installs the pip package, which (in Windows) contains ...Scriptspip.exe that path must be in PATH environment variable to use pip from the command line (see the second part of 'Alternative Instructions' for adding it to your PATH,

Alternative instructions

The official documentation tells users to install Pip and each of its dependencies from source. That's tedious for the experienced and prohibitively difficult for newbies.

For our sake, Christoph Gohlke prepares Windows installers (.msi) for popular Python packages. He builds installers for all Python versions, both 32 and 64 bit. You need to:

  1. Install setuptools
  2. Install pip

For me, this installed Pip at C:Python27Scriptspip.exe. Find pip.exe on your computer, then add its folder (for example, C:Python27Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:

pip install httpie

There you go (hopefully)! Solutions for common problems are given below:

Proxy problems

If you work in an office, you might be behind an HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:


If you're really unlucky, your proxy might be a Microsoft NTLM proxy. Free software can't cope. The only solution is to install a free software friendly proxy that forwards to the nasty proxy.

Unable to find vcvarsall.bat

Python modules can be partly written in C or C++. Pip tries to compile from source. If you don't have a C/C++ compiler installed and configured, you'll see this cryptic error message.

Error: Unable to find vcvarsall.bat

You can fix that by installing a C++ compiler such as MinGW or Visual C++. Microsoft actually ships one specifically for use with Python. Or try Microsoft Visual C++ Compiler for Python 2.7.

Often though it's easier to check Christoph's site for your package.

Thursday, October 13, 2022

As ?smail said there's no install step for Qt on Windows. However one can try to approximate it by performing the following operations.

  1. Cleaning
    Run make clean in the build folder to remove all temporary files.
  2. Moving
    Copy build folder to the place where you want Qt "installed". Let's call it INSTALL_DIR.
  3. Fixing paths hardcoded in the qmake.exe executable
    Run qmake -query to see what paths are compiled (hardcoded) into qmake and
    a. Fix paths containing the build folder by replacing it with the INSTALL_DIR using qmake -set (1).
    b. Create a qt.conf file in the bin subfolder of the INSTALL_DIR specifing new Qt paths inside it.
  4. Adding current directory to include path
    In Qt's provided binary distributions, the pwd is included in the QMAKE_INCDIR and thus ends up in your projects include path as ".". This does not happen by default in a custom built Qt, so you have to add the following line to mkspecs/YOUR-PLATFORM-HERE/qmake.conf file:
    QMAKE_INCDIR += "."
  5. Fixing prl files
    When you add a Qt component to a project file (such as CONFIG += uitools), Qt looks in %QTDIR%/lib/QtUiTools.prl to find the library dependencies of that component. These files will have the hard coded path of the directory in which Qt was configured and built. You have to replace that build directory with the one to which you moved Qt for all lib/*.prl files.
  6. Making source available
    If you made a shadow build (build made inside folder other than the one containg sources), headers in the include subfolder only forward to the original headers. For example; BUILD_DIRincludeQtCoreqabstractanimation.h looks like this
    #include "SRC_DIR/src/corelib/animation/qabstractanimation.h"
    If you don't want to depend on the existence of the folder containg sources you have to copy SRC_DIR/src subfolder to your destination folder and fix all headers in the include folder so that they forward to the new location of src subfolder.

The bottom line:
The build process of Qt under Windows makes it really akward to move (install) Qt after building. You should do this only if ... well I can't find any good reason to go through all this trouble.

The easy way is to place Qt's sources in the folder where you want Qt to stay after building and make a build in this folder. This makes all steps but 1 and 4 above unnecessary.

The variables you set with qmake -set are saved in the registry key
Because of this you might have a problem when you would like to have different projects using different versions of Qt which happen to have the same version of qmake. In this case the better solution is to use qt.conf file (actually files as you need one file for each Qt installation) (option 3b).

Many of the information above come from the RelocationTricks wiki page authored by Gabe Rudy. Check out his Qt (Qt4) Opensource Windows Installers of Pre-built Binaries with MSVC 2008 project which gives you easy solution of above problems.

Tuesday, August 23, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :