---
title: "PHP 开发环境搭建( Eclipse PDT XAMPP XDEBUG)"
author: "yangzb"
date: "2009-12-31T23:32:30Z"
tags: ["Apache", "C", "Eclipse", "PHP", "Zend"]
categories: ["非技术"]
slug: "php-eclipse-pdt-xampp-xdebug"
draft: false
lastmod: "2009-12-31T23:35:28Z"
id: 560919
url: "https://yangzb.iteye.com/blog/560919"
---

**1.下载和安装配置XAMPP**

 

我下载的是，XAMPP Lite（精简版） ZIP 压缩包，下载地址

[http://www.apachefriends.org/zh\_cn/xampp-windows.html](http://www.apachefriends.org/zh_cn/xampp-windows.html)

 

根据xampp的文档描述，解压到根目录意味着您可以直接使用，不需要先运行“setup\_xampp.bat”进行配置

(参见：[http://www.apachefriends.org/zh\_cn/xampp-windows.html#1721](http://www.apachefriends.org/zh_cn/xampp-windows.html#1721) )

所以我的解压路径是 C:/xampplite

 

运行 xampp-control.exe，启动 apache

访问 [http://localhost/xampp/phpinfo.php](http://localhost/xampp/phpinfo.php)

可以看到apache使用的PHP配置文件为：C:\\xampplite\\apache\\bin\\php.ini

 

打开php.ini，在最后加入以下配置信息，以启用xdebug 

Php.ini 配置代码

```
;载入Xdebug
zend_extension_ts="c:/xampplite/php/ext/php_xdebug.dll"

;xdebug配置
[Xdebug]
;开启自动跟踪
xdebug.auto_trace = On
;开启异常跟踪
xdebug.show_exception_trace = On
;开启远程调试自动启动
xdebug.remote_autostart = On
;开启远程调试
xdebug.remote_enable = On
;收集变量
xdebug.collect_vars = On
;收集返回值
xdebug.collect_return = On
;收集参数
xdebug.collect_params = On
```

 

重启apache，后刷新 phpinfo.php 页面，如果能见到 XDebug 的信息，就说明配置成功

 

 

**2.安装配置eclipse pdt**

到 [http://www.java.com](http://www.java.com/)  下载安装JRE

到 [http://www.eclipse.org/pdt/downloads/](http://www.eclipse.org/pdt/downloads/)  下载 PDT All In Ones

解压后，运行双击eclipse.exe运行pdt，选择workspace(我的是E:/pdt-ws)

 

打开window -&gt; perference -&gt; PHP-&gt;PHP executables

新增一个executable：

Name: xampplite-php

Executable path: C:\\xampplite\\php\\php.exe

PHP ini file: C:\\xampplite\\apache\\bin\\php.ini

PHP Debugger: XDebug

打开window -&gt; perference -&gt; PHP-&gt;Debug，设置：

PHP Debuger: XDegug

Server: Default

PHP Executable: xampplite-php

uncheck "Break at first line"

**3.调试php项目**

新建项目proj1，并新建一个index.php，输入适当的PHP代码，然后设一个断点

打开apache配置文件 httpd.conf，在最后增加：  

Httpd.conf代码

```
Alias /proj1  E:/pdt-ws/proj1/
Alias /proj1/ E:/pdt-ws/proj1/
<Directory "E:/pdt-ws/proj1/">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all  
</Directory>  
```

 重启apache

 

回到eclipse pdt，右击index.php，

选择 Debug As --&gt; PHP Web Page 就可以进行断点调试了