Configure the php development environment and phpunit and xdebug in win7

Source: Internet
Author: User
Tags php development environment vc9
First, declare that the following configuration process is performed under win732-bit Professional Edition. Next, enter the topic: Configure WAMP and install appserv: 1. Download appserv. AppServ is a PHP Web site shelving tool package. The author repacks free site shelving resources on the network into a single installer to help beginners quickly complete the site Shelving and AppS

First, declare that the following configuration process is performed under win7 32-bit Professional Edition. Next, enter the topic: Configure WAMP and install appserv: 1. Download appserv. AppServ is a PHP Web site shelving tool package. The author repacks free site shelving resources on the network into a single installer to help beginners quickly complete the site Shelving and AppS

First, declare that the following configuration process is performed under win7 32-bit Professional Edition. Enter the topic below:

Configure WAMP and install appserv:

1.Download appserv. AppServ is a PHP Web site shelving tool package. The author repacks free site shelving resources on the network into a single installation program to help beginners quickly complete the site shelving, appServ includes the following software: Apache, Apache Monitor, PHP, MySQL, and phpMyAdmin.

2.Run the downloaded appserv as administrator. You can choose to install it on disk D. The default port number is 80. In addition, you need to enter the host name, email address, and so on, you also need to set the mysql password. Remember this password after setting it. After next, the installation will be completed. Some files will appear in the D: \ AppServ \ www directory. The files in this directory are webpages that can be run locally, you can access your own html webpage or php Webpage Through the apache server. At this time, there is an index. php file in the www directory, which is opened in the browser. If the page shown appears, it indicates that appserv has been installed successfully.


To enable the webpage to prompt the syntax error of the php program we have compiled for debugging, we will do the following:

First, write a php program te. php with a syntax error, as shown below:

Echo "hello"
Echo "world ";
?>

After saving, run the php program on the webpage. If a syntax error prompt is displayed on the webpage, the default configuration displays a syntax error. At this time, we do not need to make any modifications, however, if you run this program and the webpage does not display any prompts and the results are caused by network disconnection, we need to modify the following two parameters:

Display_errors = On

Error_reportingE_ALL &~ E_NOTICE

Save, restart the apache server, and continue to run the php program with a syntax error. At this time, a syntax error is prompted.


Install pear:


Pear is a PHP extension and application library. It contains many useful classes. After the above appserv is installed, the php module in appserv does not actually have pear, so we need to install pear. You can install pear in two ways.

I. go-pear.bat files

First, open your php installation directory (My is D: \ AppServ \ php5), check whether there is a go-pear.bat under this path, if there is, congratulations, this installation will be a little simpler. Double-click the go-pear.bat, if php_mbstring.dll is not found, then open C: \ Windows \ php. ini, find extension = php_mbstring.dll, put this sentence in front of extension = php_exif.dll, and save. The cause of the error is that exif needs to call mbstring, so mbstring must be in front. However, you cannot figure out why mbstring is placed behind by default.

Double-click the go-pear.bat,

Enter system, press enter,

Press enter to complete the installation. Then,

Enter Y, press enter,

Continue to press enter,

In this case, pear is successfully installed. Press enter.

Now that pear is successfully installed, we need to tell php where my pear is installed. Therefore, open php. ini and find the following content:

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories;
;;;;;;;;;;;;;;;;;;;;;;;;;


; UNIX: "/path1:/path2"
; Include_path = ".:/php/shortdes"
;
; Windows: "\ path1; \ path2"
; Include_path = ".; c: \ php \ shortdes"

Remove the semicolon from the last line and change it to the installation directory of your own PEAR. For example, my name is include_path = ".; D: \ AppServ \ php5 \ PEAR"

At this time, check the php installation directory and find pear. bat and PEAR_ENV.reg are added. Restart the apache server first,

Double-click the PEAR_ENV.reg file and select "OK" to import the registration information of pear (why is the import still unclear ).

Next, set the environment parameters, double-click the pear. bat file, open cmd, and enter the pear version. if the version information is displayed, the installation is successful.

Enter the pear list. The pear package list is displayed. phpunit requires the pear benchmark package. If no Benchmark is available, enter pear install Benchmark on the command line to install it.

After the installation is successful, enter pear list to view the installed pear library,

Benchmark, OK.

The directory structure of pear is as follows:


By default, the cfg www folder is empty. Each time you run the pear command to install a software package in the data docs pear file, a folder is created to save the software data, for example, installing phpdocumentor, the phpdocumentor folder is available in these three folders.

Now, we need to update pear and input pear upgrade-all in the command line. If the error message is displayed, try it several times. This is because some packages have requirements on the pear version, after the first execution, run pear version. You can find that the pear version has been upgraded, and then run pear upgrade-all. It also indicates the packages that cannot be upgraded due to version requirements.

Stop until no updates are available.

At this time, because pear is updated, run PEAR_ENV.reg again to import information to the registry to prevent errors.


2. No go-pear.bat files

If your php installation directory does not have a go-pear.bat file, it doesn't matter, some integration packages don't have this thing, at this time, click here

Download the file go-pear.phar in the Link, after the download is complete put the file in the php installation directory, and then copy a go-pear.phar file, modify the name of the go-pear.php, also put in the php installation directory. Open dos, enter the php installation root directory run go-pear.php, will open the go-pear.php window, and then turn off it, then you can follow the normal process to install phpunit.


Install phpunit:


Add channels to pear and execute the following commands in the php installation directory:

Pear channel-discover pear.phpunit.de
Pear channel-discover components. ez. no
Pear channel-discover pear.symfony-project.com

Pear install -- alldeps phpunit/PHPUnit (this statement indicates all elements of PHPUnit installation. If pear install phpunit/PHPUnit is run, only a part of files are installed, an error may be reported when writing the test, so all elements of PHPUnit are installed here. If pear install phpunit/PHPUnit is run before, delete php/pear/phpunit, run pear install -- alldeps phpunit/PHPUnit, or run pear clear-cache to clear the cache, then pear install-a-f phpunit/PHPUnit to reinstall .)).

After the installation is successful, run phpunit -- version. if the version information is available, it indicates that phpunit is successfully installed.


Now, you have installed a phpunit test environment for your php runtime environment. You can write test cases and run the phpunit command.


Install Xdebug:

Xdebug isOpen source codeThe PHP program debugger (a Debug tool) can be used to track, Debug, and analyze the running status of PHP programs. Next we will introduce how to install xdebug.

First, test it. Enter http: // localhost/phpinfo. php in the address bar to check the Thread Safety field. If it is enabled, Your php is Thread safe.

Thread Safe is Thread security. During execution, the Thread security check is performed to prevent the new Thread from consuming system resources by starting the CGI execution mode. Non-Thread Safe is Non-Thread security and does not perform Thread security checks during execution.

The preceding Thread Safety = enabled parameter indicates that the Thread is secure. Therefore, to export (dll), be sure to download the xdebug version corresponding to your php version. Otherwise, xdebug will become unavailable, it involves the following aspects:

(1) Thread Safe is Thread security. During execution, the Thread security check is performed to prevent the new Thread from consuming system resources by starting the CGI execution mode. Non-Thread Safe is Non-Thread security and does not perform Thread security checks during execution.

(2) VC6 is compiled using the Visual Studio 6 compiler. If you are using Apache + PHP in windows, select VC6.

VC9 is compiled using the Visual Studio 2008 compiler. If you are using IIS + PHP in windows, select VC9.

(3) In Windows, PHP can be executed in two ways: ISAPI and FastCGI.

The ISAPI is executed in the form of a DLL dynamic library. It can be executed after a user request and will not disappear immediately after processing a user request. Therefore, thread security check is required, in this way, the program execution efficiency is improved. If you use ISAPI to execute PHP, we recommend that you select the Thread Safe version;

FastCGI executes operations in a single thread, so it does not need to perform thread security checks. Apart from the thread security check protection, it can improve the execution efficiency. Therefore, if FastCGI is used to execute PHP, we recommend that you select the Non-Thread Safe version. We do not recommend that you use Non-Thread Safe in the production environment.


After you open the http://xdebug.org/download.php network, you will see a lot of debugging operations,

It is thread-safe to have the TS suffix. At this time, I should download the TS suffix and VC6, and my php version is 5.2, my windows is 32-bit, so I want to download php_xdebug-2.1.2-5.2-vc6.dll. You should download the corresponding xdebug based on your php version and other information.

Place the downloaded file in the php root directory/ext, Open C: \ Windows \ php. ini, and add the following content:

[Xdebug]

Zend_extension_ts = "D: \ AppServ \ php5 \ ext \ php_xdebug-2.1.2-5.2-vc6.dll"
Xdebug. auto_trace = on
Xdebug. collect_params = on
Xdebug. collect_return = on
Xdebug. profiler_enable = on
Xdebug. trace_output_dir = "d: \ xdebug"
Xdebug. profiler_output_dir = "d: \ xdebug"
Xdebug. remote_enable = on
Xdebug. idekey = ""
Xdebug. remote_handler = dbgp
Xdebug. remote_host = localhost
; Xdebug. remote_port = 8888
Xdebug. remote_port = 9000

Note 1: Download the corresponding xdebug according to the PHP version. do not mess up or not match. VC6 VC9, security mode, and so on. It corresponds to many versions. run phpinfo to view your version !!!!! This is the most important one! 2; the address in the first line above should be modified. According to the value stored by myself, the bottom address is for storing records. You can just do it yourself.

Restart apache and refresh http: // localhost/phpinfo. php. If the xdebug configuration parameters appear on the page, the xdebug installation is successful.



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.