Heim  >  Artikel  >  Backend-Entwicklung  >  浅谈Eclipse PDT调试PHP程序_PHP教程

浅谈Eclipse PDT调试PHP程序_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:28:45979Durchsuche

1. 下载eclipse,从官网上找就可以了,并确认当前系统中有java环境,即jdk和jre。

2. 安装pdt了,采用的是在线安装,更新地址在默认中已经包含了。只是更新起来比较麻烦。(如果直接下载 携带PDT的 Eclipse版本,可省略)

3. 下载调试器,调试器有两种,一种时xdebug,另一种时zenddebug,本文采用 xdebug。

下载下来的应该是源代码包。解压缩,然后cd到目录,然后phpize,有的时候可能没有这个程序,运行sudo apt-get install php5-dev,就可以了。然后就会出现熟悉的config程序 ./configure 出现一连串黑白屏字符,接着make,make install。后两项命令执行的时候,可能会需要sudo权限,因为涉及到将程序文件复制到系统目录。

4. 在/etc/php5/apache2/conf.d/中建立一个xdebug.ini文件,可以用vi或者其他文本程序,加入如下的配置项目。配置内容如下:

复制代码 代码如下:

[xdebug]
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.auto_trace=on
xdebug.collect_params=on
xdebug.collect_return=on
xdebug.max_nestring_level=100
xdebug.profile_enable=on
xdebug.remote_enable=on
xdebug.remote_host=localhost
xdebug.trace_output_dir="/tmp"
xdebug.profile_output_dir="/tmp"
xdebug.idekey=webide
xdebug.mode=req

放到这个目录中的ini文件会被php自动加载。

至此,xdebug的安装配置已经完成。

5. 打开eclipse,然后选择window preference , 先配置服务选项:

先配置debug,选择php选择debug,将php的debugger选择为xDebug。接着配置Server,
选择PHP Servers,然后弹出菜单:然后点击new,在Name处随便选择一个名字,url配置成调试的主url。
然后设置成default。
最后配置PHP Executables,add 随便起个名字,path设置成/usr/bin/php 然后设置ini的位置在/etc/php5/apache2/php.ini
SAPI Type应该设置成CGI, 但是好像调整不过来,不知道为什么。
最后将PHP debugger设置成为XDebug就可以了。

6.   一切准备就绪,新建一个php project ,这些得能在你的apache找到,然后新建一个php页面,写入一段代码,加上几个断点,然后右击php页面选择debug as phpscript就可以看到熟悉的调试窗口了,可以看到变量列表,post,get的值等。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/781031.htmlTechArticle1. 下载eclipse,从官网上找就可以了,并确认当前系统中有java环境,即jdk和jre。 2. 安装pdt了,采用的是在线安装,更新地址在默认中已经包...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn