Home Backend Development PHP Tutorial Eclipse+php插件+Xdebug筹建PHP完美开发/调试环境指南

Eclipse+php插件+Xdebug筹建PHP完美开发/调试环境指南

Jun 13, 2016 pm 01:07 PM
debug eclipse php xdebug

Eclipse+php插件+Xdebug搭建PHP完美开发/调试环境指南

最近要开始使用Zend框架开发中型应用系统了,由于采用完全面向对象的框架思路开发程序,不光开发思想,先前的Editplus+Dreamweaver编辑器组合显然不能满足我的要求了。我的新环境初步定为Eclipse+PDT插件+Xdebug+apache(Unix平台最流行的WEB服务器平台)。

  先前一直对dotNET、Java的IDE的代码自动嗅探、代码提示、程序断点调试等等自动化功能羡慕不已,而自己写PHP只能靠着echo、var_dump()来调试程序,能不能让PHP也实现断点调试呢?先前在Eclipse的PHP插件中发现了Debug的选项,说明调试功能应该是可行的,但是不知道是怎么个配置法,跑上google查找资料发现没有一个完整的介绍配置文档,我只能将获得的信息拼接起来后来测试。

  结果是:完美实现PHP断点调试!

  =====================================================

  本文系原创文章,转载请注明文章源自思想之地,作者:朦胧中的罪恶

  =====================================================

  下面就是详细过程。

  步骤一:

  1.首先下载并安装相应软件

  Jdk是绝对必要的,它是跑Eclipse的最基本要求,到这里下载。

  Eclipse整合了PHP开发插件版本在这里下载,选择对应自己的操作系统的版本后下载到本地即可。

  XDebug到这里下载,请根据自己PHP的版本选择相应文件下载。

  服务器任意,推荐使用apache(Unix平台最流行的WEB服务器平台)+PHP模块安装方式。

  2.软件安装

  首先安装JDK后,安装好后请按照下面步骤配置系统变量

  其次是安装Eclipse,Eclipse不用怎么设置,只要设置好了JDK,Eclipse放置于任何位置都可以直接运行

  最后Xdebug安装

  我自己使用的是PHP5.2.5,下载的xdebug文件名为:php_xdebug-2.0.3-5.2.5.dll,将文件放到php/ext文件夹下即可

?

xdebug配置

  打开php.ini

  在最后一行加入以下配置代码,配置说明已经做好注释

  ;载入Xdebug

  zend_extension_ts="c:/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

  注意zend_extension_ts后面的路径要填写绝对路径,保存后重启服务器即可。

  此时用phpinfo()查看php配置,如果安装成功,应该可以看到以下信息:

  下面是eclipse的配置

  详细配置请看下图说明(所有图片均可点击放大查看)

  eclipse全局总体配置:(点击放大查看)

  

  测试服务器配置:在上面窗口中点击 PHP Server....  后(点击放大查看)

  

PHP项目总体配置:打开或新建一个php项目后,在项目上单击右键,选择 Properties(点击放大查看)

     

  按照自己的实际要求配置好之后,整体的调试环境就完全配置好了,开始enjoy吧!

  下面介绍如何开始调试

  1.首先打开你要调试的页面,我这里以emlog首页index.php为例

  在eclipse的菜单中照图中的顺序选择:

  

  这时eclipse就会启动debug界面,效果截图:(点击放大)

  

  如果你的服务器配置正确,那么就会蹦出浏览器并看到程序页面了。

  现在进入重点,很酷的PHP断点调试功能

  在你要设定断点的行上点击右键,选择 Toggle Breakpoints

  

  设定好之后,请再启动debug

  下面是个例子(点击放大)

  

?

  有人肯定会问,这是首页,如果我要调试的页面带有参数或者不能直接访问怎么办?

  答案很简单,你只要在需要的调试的页面上设定断点,debug时启动任何一个可以直接访问的页面,然后从页面上点击到你要访问的页面,或者访问调用你要调试的文件的页面即可,运行到断点的时候eclipse会自动跳出来,这时你就可以开始调试了。

本文来源于 WEB开发网 原文链接:http://www.cncms.com.cn/php/14008_3.htm

?

?

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles