- based on wamp and Eclipse for PHP Developers
In order to build a PHP development and debugging environment, I have consulted countless information on the Internet, but none of it is really feasible. Because the PHP development environment requires many kinds of software to cooperate with each other, the versions of the software must match each other, and it is difficult to say exactly how to match each other. As for the matching of the latest versions of software, there is even less corresponding information. Even if there is a slight version mismatch between versions, the final result will be in vain.
However, through unremitting persistence and hard work, after failing again and again, I finally completed the PHP development and debugging environment at 1:30 in the morning. When I saw that after running the web page, Eclipse automatically entered the breakpoint, I Not to mention how excited I was. In order for PHP newbies to avoid detours (actually, I am also a novice, and I don’t understand PHP syntax at all), I will summarize the construction process, hoping to be helpful to my friends.
XP SP3
Download address: http://www.wampserver.com/en/#download-wrapper
I placed
It contains 4 necessary software to build PHP:
Why use WampServer?
Because if you install these software separately, first of all, it is very troublesome to install them one by one; secondly, each software must be configured; thirdly, the versions of the software you install may not match each other; finally, due to inconsistent versions, There may be subtle differences in configuration. It is much better to use WampServer. It contains all the software to build a PHP development and debugging environment, and there are very few configurations required. Of course, you do not need to consider the matching between versions. Finally, the reason why I adopted WampServer was because I made the decision to adopt WampServer, a one-stop service, after I tried to install each software N times but failed.
Download address: http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliossr1
I downloaded the 32-bit version:
This is an IDE provided by eclipse for PHP developers. For those who are accustomed to using eclipse to develop, it is best to use it to develop PHP. Of course, after all software is installed, we still need to make some configurations for this IDE to be able to debug PHP. We will talk about this later.
Just keep going to the next step. If you encounter setting up SMTP, just set it up casually.
After the installation is completed, my installation directory is: C:wamp
Directory structure after installation:
As you can see from the picture: the three basic software we need, apache, php, and mysql, are all in the bin folder in the installation directory. In addition, the www directory is the website directory of the apache server. After installing Eclipse for PHP Developers, the workspace will be set to this directory.
Install Eclipse for PHP Developers
I unzipped it to D:softwaredevelopphpeclipse. You can customize the location according to your preferences.
Configuration software
As shown in the figure: open short open tag and load apache’s rewrite module
Apache configuration
Enter C:wampbinapacheApache2.2.21conf, open httpd.conf, find the line Listen 80 and change it to Listen 81, and save it. Restart apache.
At this time, enter: http://localhost:81/ in the browser and you will see the following interface:
It contains all the functions of our wamp server. Click the phpinfo() link to view the installation status of php
Many information on the Internet requires you to manually download Xdebug and configure it yourself. However, this version of WampServer already includes Xdebug (located under C:wampbinphpphp5.3.8zend_ext) and is automatically configured. So we basically don’t need to configure anything. The only thing we need to configure is to open php.ini under C:wampbinapacheApache2.2.21bin, find xdebug.remote_enable = off in the last few lines, and change it to xdebug.remote_enable = on. This is done so that breakpoints can be entered when debugging in eclipse.
Click the phpinfo() link in http://localhost:81/. If there is the following information, xdebug has been installed correctly:
First you need to configure jdk. This requires you to install the jdk package first, and then set the environment variables. There are too many configuration articles on the Internet, you can refer to them for configuration.
The focus of this article is to enable Eclipse for PHP Developers to support PHP debugging. Let’s take a look at how to configure PHP in Eclipse for PHP Developers:
When opening Eclipse for PHP Developers, you need to set up the workspace. This must be set to the www directory of wamp, otherwise debugging will not be possible later. My www directory is C:wampwww
Enter Eclipse -- Window – Preferences
Set PHP Executable. You need to pay attention to the path of PHP.INI. The path here is unique to WAMP SERVER and is placed in the apache directory
Just set the PHP Server to the default. Since we changed the apache port to 81, we need to make corresponding modifications here:
Since the built-in browser is used for debugging by default, which is very inconvenient, I changed it to the chrome I am used to:
Create a PHP project and create my.php as a test page
Enter the following code in my.php and add a breakpoint on the second line:
PHP Web is used here To debug in Page mode, you need to set xdebug.remote_enable in php.ini under C:wampbinapacheApache2.2.21bin = on, indicating remote debugging is enabled. Of course, this step has been configured in the previous Xdebug configuration.
After debugging is started, the chrome browser will automatically start and open
http://localhost:81/test1/my.php?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=13380120483901 this page, and automatically enter the breakpoint:
After the execution is completed, the page display effect:
At this point, the PHP development and deployment environment has been officially completed. It can be seen that the process is very complicated and cumbersome, but as a qualified developer, we should have the determination and confidence to get it done. In this tossing process We will accumulate valuable experience. I hope this document can be helpful to everyone, thank you!