Home  >  Article  >  php教程  >  PHP Eclipse PDT debug调试环境搭建

PHP Eclipse PDT debug调试环境搭建

WBOY
WBOYOriginal
2016-06-06 19:59:111076browse

本贴子使用的环境 为: win7 32 PHP Version 5.2.17 thread safe apache 2.2 Zend Eclipse PDT Studio Web Debugger 之前一直是搞J2EE的,最近公司要用到PHP,想自己搭下PHP的开发环境,怎耐周围没有熟悉的人。。。 只能自己动手丰衣足食,其中遇到不少困难

       

本贴子使用的环境 为: win7 32  +  PHP Version 5.2.17 thread safe +apache 2.2 + Zend Eclipse PDT +Studio Web Debugger

   之前一直是搞J2EE的,最近公司要用到PHP,想自己搭下PHP的开发环境,怎耐周围没有熟悉的人。。。

只能自己动手丰衣足食,其中遇到不少困难,于是心想这PHP不是最流行的WEB开发语言么,怎么配置起来

这么困难,本人认为最困难的是eclipse +xdebug +zend debugger  +php它们都有N个版本,能组合上统一的

版本是多么的困难,尽管网上有N多教程,但看了之后发现和自己装的都不一样。

           于是乎决定如果弄好这个环境一个一定要自己写一个贴子,分享给大家。



http://blog.csdn.net/gaochh01/article/details/6949178

 这里我们重点讲eclipse的DEBUG调式环境

1.首先下载eclipsePDT,这里有一个集成了所有PHP需要的组件的下载地址,有了它, 你就不用麻烦的去下eclipse又去找对应的php插件了,

它集成了所有php所要用的插件,具体请看下面的链接

http://www.zend.com/en/community/pdt/downloads

找到windows 版本的下载TAB页,你需要下载   1. Zend Eclipse PDT    PDT 3.0.2 w/Eclipse Indigo

                                                                                    2.Studio Web Debugger


               分别解压 eclipse-php-3.0.2.v20120511142-Win32.zip

                           和  ZendDebugger-20110410-cygwin_nt-i386.zip

               你会发现  ZendDebugger-20110410-cygwin_nt-i386 下有N个文件夹,4_3_x_comp,4_4_x_comp。。。。。,这要选

哪一个是好呢? 别急,首先我们安装的是PHP Version 5.2.17 thread safe 版本的php,所以我们选择5_2_x_comp 文件夹里的

内容,你要问了5_2_x_nts_comp 这个是作什么的, 我来给你讲一下他们的区别

5_2_x_comp   是针对  thread safe版本的php

5_2_x_nts_comp 是针对 non -thread - safe版本的php,因为我们装的是 PHP Version 5.2.17 thread safe,所以我们使用5_2_x_comp

打开5_2_x_comp 里面有一个 ZendDebugger.dll文件

1).copy  ZendDebugger.dll 到   [your php path]/ext/  例如我的路径为:C:\Web\php\ext

2).打开 php.ini文件   在最后加上

                    [zend debugger]
                    zend_extension_ts="C:\Web\php\ext\ZendDebugger.dll";同样注意ts和完整的路径。这里写你自己的php安装路径
                   zend_debugger.allow_hosts=127.0.0.1;允许调试的主机IP,
                   zend_debugger.expose_remotely=always;

3).打开apache /conf/httpd.conf文件,在356行左右加入

                   Alias /pdt/ "D:/workspace3.3_PHP/"
                   
                      Options Indexes FollowSymLinks MultiViews
                      AllowOverride all
                      Order Deny,Allow
                      Allow from all
                   

你又要问了 这是干什么?

其中D:/workspace3.3_PHP/ 是你eclipse的工作目录  ,大概意思就是如果你请pdt它会给你转到  D:/workspace3.3_PHP/,可能不太准确

但意思差不多

重启apache后,你就可以直接通过 http://localhost/pdt/去直接访问eclipse工程中的D:/workspace3.3_PHP/ 文件了,这会在之后用到

4).copy  C:\Web\php PDT\ZendDebugger-20110410-cygwin_nt-i386 中的 dummy.php到 appache /conf/htdocs 文件夹内


重启 apache 服务

如果你在phpinfo()中看到           

                                                                                Zend Debugger

Passive Mode Timeout 20 seconds

Directive Local Value Master Value
zend_debugger.allow_hosts 127.0.0.1 127.0.0.1
zend_debugger.allow_tunnel no value no value
zend_debugger.deny_hosts no value no value
zend_debugger.expose_remotely always always
zend_debugger.httpd_uid -1 -1
zend_debugger.max_msg_size 2097152 2097152
zend_debugger.tunnel_max_port 65535 65535
zend_debugger.tunnel_min_port 1024 1024

那么恭喜你,已经成功一半了

,接下来我们打开eclipse PDT,当然我们的workspace是之前apache  httpd.conf 配置中的D:/workspace3.3_PHP/


1).   windows ----> preference ---> PHP----->PHP Executables ----------->add

                        name : test   此项随意

                        Exceutable path:  C:\Web\php\php.exe    你自己的php安装路径

                        PHP ini file  :C:\Web\php\php.ini    你自己的php安装路径

                       SAPI TYPE: CLI

                       PHP debugger:  Zend Debugger

                        然后确认保存

2).windows ----> preference ---> PHP--------->  PHP Servers

                       name : Default PHP Web Server    随意

                       Base URL: http://127.0.0.1

                       local Web Root:  空

                       然后确认保存

3). windows ----> preference ---> PHP------------->Debug

                       PHP Debugger :  Zend Debugger

                       Server: Default PHP Web Server(2中配置的)

                        PHP Excutable:test   (1 中配置的)

4).Enable CLI Debug  前面勾打上

然后确认保存


5).新建一个PHP工程 name:test

                     新建一个php文件  new.php

                             输入:

 6):点击debug configuration ----------->PHP Web Application

                    双击新建一个configration   Name :随意

                      Server

                       Debugger: Zend Debugger

                       PHP Server :   Default   PHP  Web Server  (之前步骤中创建的)

                       File : 选中 /test/new.php

                       URL  下 auto Generate  前面的勾去掉

                        URL: http://127.0.0.1/                  /pdt/test/new.php这处注意修改

你又要问了  为什么要加pdt  ?? ,因为我们之前在apache /conf/httpd.conf

                   Alias /pdt/ "D:/workspace3.3_PHP/"
                   
                      Options Indexes FollowSymLinks MultiViews
                      AllowOverride all
                      Order Deny,Allow
                      Allow from all
                   

如果不加pdt  默认请求的是C:\Web\apache\htdocs目录下的文件,就会提示找不到

/test/new.php,这样你知道为什么要加ptd 了吧

然后点击debug,你就可以像调试java一样在new.php中打断点进行调试了

 

 

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