日期:2014-05-17  浏览次数:20792 次

Win7下PHP5.40 +Apache2.2.0 +MySql5.2 基于Eclipse for PHP编译器的DEBUG调试环境搭建
首先我是新手,JAVAER!由于工作需要,研究一下PHP!

开发WEB项目,如果不能DEBUG很难想象如何调试!为此,在网上找了好多,都不靠谱!走了好多弯路。。。基于Zend Stuido编译器下的DEBUG就是搭建不起来,相当郁闷!最终改为使用Eclipse!在此记录下这一周多来搭建的过程,并给出最终搭建好的环境!

最终使用Eclipse+PDT(PHP Development Tools),到eclipse官网上下载http://www.eclipse.org/pdt/downloads/ Eclipse PDT 3.0.x All In Ones集成了PDT3.0的Eclipse!点击官网上的 “These downloads include Eclipse 3.7.1 and PDT 3.0.2”进入下载页面,也即这儿http://code.google.com/p/zend-sdk/downloads/list 选择适合自己的版本,我使用的是Win7!所以我下载eclipse-php-3.0.2.v20120511142-Win32.zip !

第一步:下载后解压,使用过eclipse的人这点应该不难。

第二步:配置PHP执行程序 eclipse菜单栏-->Windows-->Preferences-->PHP-->PHP Executables-->Add,在弹出的对话框中:
Name:随便填,不过专业一点就填写成你的PHP版本,比如PHP5.4 Executable path:选择PHP的解压目录下的php.exe
PHP ini file(option):选择相同的目录!
SAPI Type:是默认的CLI
PHP debugger:选择Xdebug。

第三步:配置PHP Server eclipse菜单栏-->Windows-->Preferences-->PHP-->PHP Servers,在右边点击
New :随意,建议填写对应的,比如Apache,或者IIS
Base URL :选择默认的http://localhost+端口号,如果你的Apache的端口是默认的80端口,则这里不需要加端口,如果不是80则加上端口号,比如我的是8090,则我的Base URL是http://localhost:8090
Local Web Root:选择你的服务器的Web目录,我使用的是Apache的默认根目录为htdocs

第四步:配置PHP DEBUG eclipse菜单栏-->Windows-->Preferences-->PHP-->DEBUG,在右边上半部分

Default Settings PHP Debugger:选择Xdebug
Server:选择第三步中配置好的Server,当然你一可以根据需要再增加新的Server OK,

到此为止Eclipse配置完了!接下来配置Xdebug!

首先到Xdebug官网上下载适合你机器上当前安装的PHP版本的Xdebug,如果不知道适不适合,可以看官网的说明,在打开的链接页中点击custom installation instructions,在该页面中查看Tailored Installation Instructions定制的安装说明!随便新建一个PHP文件,如下:
 <?php phpinfo(); ?>

放到服务器下,在浏览器访问,可以查看到当前的环境信息,复制开头的部分大致如下

 PHP Version 5.4.0 
System Windows NT LIJIANLIN-PC 6.1 build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586 
Build Date Feb 29 2012 19:20:16 
Compiler MSVC9 (Visual C++ 2008) 
Architecture x86 
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" 
Server API Apache 2.0 Handler 
Virtual Directory Support enabled 
Configuration File (php.ini) Path C:\Windows 
Loaded Configuration File D:\soft\php\php.ini 
Scan this dir for additional .ini files (none) 
Additional .ini files parsed (none) 
PHP API 20100412 
PHP Extension 20100525 
Zend Extension 220100525 
Zend Extension Build API220100525,TS,VC9 
PHP Extension Build API20100525,TS,VC9 
Debug Build no 
Thread Safety enabled 
Zend Signal Handling disabled 
Zend Memory Manager enabled 
Zend Multibyte Support provided by mbstring 
IPv6 Support enabled 
DTrace Support disabled 
Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, phar 
Registered Stream Socket Transports tcp, udp 
Registered Stream Filters convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.* 



粘贴到上面打开的页面中的框中,点击Analyse my phpinfo()output!Xdebug会根据所提供的信息去判断你所需要下载的Xdebug版本,并给出你如何配置的信息! 下载适合的Xdebug的版本以后,拷贝到php目录下,或者ext目录下,总之你放哪儿那么下面的第一行就是xdebug所在位置的路径。在php.ini文件中添加Xdebug的扩展就添加如下行:

zend_extension = php解压根目录\ext\php_xdebug-2.2.0-5.4-vc9.dll 
xdebug.auto_trace=on 
xdebug.show_exception_trace=on 
xdebug.remote_autostart=on 
xdebug.remote_enable=on 
xdebug.collect_vars=true 
xdebug.collect_return=true 
xdebug.collect_params=4 
xdebug.trace_output_dir="e:/xdebug" 
xdebug.profiler_enable=on 

以上配置不做解释!自己可以看官方文档介绍,或者直译即可!通俗易懂!