Home  >  Article  >  Backend Development  >  Eclipse development PHP debugging (debug) environment configuration_PHP tutorial

Eclipse development PHP debugging (debug) environment configuration_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:47:001090browse

I recently developed using PHP and couldn’t debug it, which was very frustrating. I found an article online about setting up an environment. Some of it was out of date, and many of the details were not mentioned. It’s quite difficult for a novice like me, so I’m writing it here. This article is about my own installation process, I hope it can help everyone. Reference article link: http://www.BkJia.com/kf/201111/111881.html

The version I finally chose is as follows

APACHE : httpd-2.2.21-win32-x86-no_ssl.msi

PHP : php-5.2.17-Win32-VC6-x86.msi

Eclipse: : eclipse-php-galileo-SR2-win32.zip

ZendDebugger : ZendDebugger-v5.2-cygwin_nt-i386

The download link is as follows (you can choose other higher versions by yourself):
1. Apache, download here
2. PHP, download here Note that VC6 corresponds to the apache platform, and VC9 corresponds to the IIS platform. Pay attention to the difference between thread safety (ts) and thread unsafe (nts) in the version. When installing zenddebugger, choose the corresponding version. , the configuration files must also correspond
3. Eclipse IDE for php, download here
4. Zend Debugger, download here

1. Install software

1. apache installation

You only need to install it step by step. After the installation is completed, apache will be started. At this time, enter http://localhost/ in the browser and

will appear.

It works!

It means that apache is installed successfully.

2. PHP installation

Just install it step by step. It should be noted that when installing the PHP extension, it must be installed by default, otherwise

will appear.

"Error trying access the local web service:GetObject Failed. You will need to manually configure the web server"

It may be because the extension module cannot be found.

After installation, PHP will automatically add the following columns to the apache configuration file

view plain

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "

LoadModule php5_module "php5apache2_2.dll"

#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

At this time, you need to complete it. If you add it, it will prompt that it cannot be found. Use the command httpd -t in cmd and it will prompt that the module php5apache2_2.dll cannot be found. For example, my PHP is installed under C:Program Files/PHP. Note that the path is split using "/", not ""

view plain

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "C:/Program Files/PHP"

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

Create a file index.php in the apache document directory and enter the following content

phpinfo();

?>

Restart apache

Enter http://localhost/index.php in the browser and PHP version information will appear, indicating that PHP and apache have been successfully built

2. DEBUG environment configuration

1. ZendDebugger

Find the corresponding version from the downloaded ZendDebugger and select it according to the PHP version (my PHP is 5.2, thread-safe). At this time, you should pay attention to selecting thread-safe or unsafe. Copy the corresponding ZendDebugger.dll to the apache installation directory, for example, I Select ZendDebugger-v5.2-cygwin_nt-i3865_2_x_compZendDebugger.dll (thread-safe) to C:Program FilesPHP. Add the following lines in php.ini (modify the path according to your own situation)

view plain

zend_extension_ts=C:/Program Files/PHP/ZendDebugger.dll

zend_debugger.allow_hosts=localhost,127.0.0.1

zend_debugger.expose_remotely=always

Copy dummy.php to the corresponding document directory of apache.

2. Configure Apache

For example, if I place all Eclipse projects under E:EclipseWorkspace, then modify Apache/conf/httpd.conf and add:

at the end of the file.

view plain

Alias ​​/workspace/ "E:/EclipseWorkspace/"

 

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

The advantage of this is that all PHP projects share an apache configuration (see how to set it up below).

3. eclipse configuration

Open Eclipse->Window->Preferences->PHP:

PHP Executables->Add, set as follows:

PHP Servers->New, set as follows: Note that the W in the Workspace inside is changed to a lowercase w. If it is inconvenient to capture the picture, use the one in the original article. If you don’t change it, you will not be able to debug the page

Note that workspace is added in the URL column. This is the directory alias added in httpd.conf.

PHP Debug, as shown in the figure below, select the appropriate Debugger, Server

At this point, the configuration is complete.

Remember to restart Apache again.

Finally, build a test program to see how it works:

Create a new PHP Project and name it FirstPHPTest. Of course, we use our E:EclipseWorkspace as the Eclipse workspace directory.

Create a new PHP File in the project, such as using index.php above.

When you right-click Run As->PHP Web Page on index.php, you can see a screen similar to the following:


Author sayo.net

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478523.htmlTechArticleI have been developing in PHP recently, and it’s frustrating that I can’t debug it. I found an article online about setting up an environment, and some of it has been It's outdated and a lot of details are not mentioned, for a dish like mine...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn