[Reprint] Installs PEAR and PHPUnit for PHP under Windows

Source: Internet
Author: User
Tags install go pear

Install PEAR and PHPUnit for PHP under Windows

Roughly translated from installing PEAR and PHPUnit on WAMP and Windows 7, slightly improved.

There is a need to install PHPUnit to test the script, search for an article, and record it.

Note :
PHP 5.2 In the directory seems to have a PEAR directory, there are Go-pear.bat, this you can study on their own, see if it is available.
I am testing PHP 5.4 Here, the default does not bring Go-pear.bat, so if you are 5.2, this tutorial is available I did not verify.

Install PEAR First

Since PHPUnit relies on PEAR, we first install the PEAR.

Modify PHP.ini

Installing PEAR on Windows is also easier, first let's set up a parameter in the next php.ini (generally in C:windowsphp.ini, if it's a green installation, look in your suite directory):

Phar.require_hash = Off

The default is commented out, we remove the preceding semicolon, and then change on to off.

Download and install Go-pear.phar

Next, go to Http://pear.php.net/go-pear.phar to download the file and put it in your PHP installation directory as an D:SERVERPHP example.
Open the CMD Command Prompt window and enter the following:

CD/D d:serverphpphp Go-pear.phar

As expected, the installation process should be no problem, wherein the configuration of the parameters you understand the changes, do not understand the direct return or Y and so on operation.

Note :
The first step is to ask if you are installing a global PEAR or local (...). I do not know how to translate the appropriate), the recommended input to the local, testing found that only the Pear.ini location is different ... But it is recommended to put the PHP directory instead of the C:windows directory.
The final step is to ask if you want to modify the include_path in the php.ini and confirm.

After modifying the php.ini, the entire installation process is finished, we restart the next Apache/nginx.

Modify the system environment variables and join the PEAR installation location

D:SERVERPHPpear ooxx...we have to set the environment variable in order for us to use it in a more elegant style, rather than typing it in a painful style each time pear install ... .

Open the Environment Variable Settings dialog box (computer-right-click-Properties-Advanced system settings-environment variable), at the system variable, locate the PATH, double-click, add:

;D: serverphp

Note that you are consistent with the location of your PHP installation and are separated from the previous configuration with semicolons.

After the PATH modification is determined, click the New button at the system variable, add an item, the variable is named PHP_PEAR_PHP_BIN , the variable value is D:SERVERPHPphp.exe , still pay attention to your installation location consistent.

Verify that the installation is correct

Open a CMD window and enter:

Set%PATH% = '. '

Then close the CMD window ...
Well, I'm not kidding you, because Windows environment variables require a reboot to take effect, here's a tip:
When you try to modify%PATH% under CMD, Windows will re-read the%PATH% in the next reply so that we can update the%PATH%.

Now reopen a CMD window and enter:

Pear

See PEAR's help information, OK, PEAR installation is complete.

Wait a minute!

Test found that you thought the installation was complete? actually otherwise
Of course, you can skip this step if you don't care about PEAR putting its installation files full on the hard drive.

After the above pit daddy configuration, I cheerfully run the following section of the command, the results found that O shit,pear batting an eye the package installed into the c:php directory.
Didn't I tell you to install it under the d:serverphp directory I set? Well? How can you be so cheeky? Well?

Let's look at the configuration of PEAR, open CMD, enter:

Pear Config-show

So, you find that your previous configuration of PEAR up to 12 items is basically futile, and the YA is still the default value ...
All right, one item is manually changed back:

Pear config-set php_dir d:serverphppear ...

Finally, in order for the previously installed package to use the new configuration, we need to force the reinstallation once:

Pear Upgrade--force

OK, finally the installation is complete.

Installing PHPUnit

The rest is a lot easier.

Open CMD and enter the following command:

Pear upgrade Pearpear channel-discover components.ez.nopear channel-discover pear.phpunit.depear channel-discover Pear.symfony-project.compear Install--alldeps Phpunit/phpunit

Wait for the installation to complete, we enter phpunit to verify the installation:

PHPUnit 3.6.10 by Sebastian Bergmann.Usage:phpunit [Switches] unittest [unittest.php]       PHPUnit [Switches]  -- Log-junit        Log test Execution in JUnit XML format to file.  --log-tap          log test execution in tap format to file.  --log-json         log test execution in JSON format.  --coverage-clover  Generate Code Coverage report in Clover XML format.  --coverage-html
Generate Code Coverage report in HTML format.--coverage-php Serialize php_codecoverage object to file.--coverage-t ext= Generate Code Coverage report in text format. Default to writing to the standard output. ...

Well, it's OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.