Home php教程 php手册 使用zend studio配置Xdebug调试PHP教程

使用zend studio配置Xdebug调试PHP教程

Jun 06, 2016 pm 07:47 PM
studio xdebug zend use debug Configuration

之前我介绍了 PHP开发工具Zend Studio7入门使用教程 ,其实使用zend studio调试PHP非常方便,zend studio默认支持调试工具zend debugger,也允许使用第三方调试工具,今天以PHP教程形式分享如何使用zend studio配置Xdebug来调试PHP程序。 使用Xdebug在zend st

之前我介绍了PHP开发工具Zend Studio7入门使用教程,其实使用zend studio调试PHP非常方便,zend studio默认支持调试工具zend debugger,也允许使用第三方调试工具,今天以PHP教程形式分享如何使用zend studio配置Xdebug来调试PHP程序。

  使用Xdebug在zend studio中调试PHP源码之前,请务必安装配置Xdebug,这是基础教程,可参考PHP调试工具Xdebug安装配置教程一文,Xdebug结合zend studio在配置方面还是有点区别的。

  在zend studio中使用Xdebug调试PHP源码之前,需要针对zend studio对Xdebug进行配置,否则无法使用Xdebug调试PHP。

  针对zend studio配置Xdebug的教程

  打开PHP安装目录下的PHP.INI配置文件,我的是C:\PHP目录,找到Xdebug配置信息,在此基础上添加如下Xdebug配置信息

 

使用zend studio配置Xdebug调试PHP教程使用zend studio配置Xdebug调试PHP教程代码

xdebug.remote_enable=true      //Xdebug允许远程IDE连接
xdebug.remote_host=127.0.0.1   //允许连接的zend studio的IP地址
xdebug.remote_port=9000        //反向连接zend studio使用的端口
xdebug.remote_handler=dbgp     //用于zend studio远程调试的应用层通信协议

 

 

重要说明:这里容易忽视的一个问题是xdebug.remote_host信息的配置,如果你使用的是局域网或无线路由器,将xdebug.remote_host配置为127.0.0.1是无用的,会导致无法使用zend studio调试PHP,zend studio的单步调试按钮也无效!必须将xdebug.remote_host配置为zend studio安装机器的实际地址,IP地址可以通过ipconfig查看,由于我使用的是无线路由器,所以我将xdebug.remote_host配置为192.168.1.100。

  最后重启apache服务器。

  Ok,下面我们就可以使用Xdebug在zend studio中进行调试工作了。

  由于zend studio默认支持调试PHP的工具是zend debugger,所以首先需要将zend studio PHP Debug选项配置为Xdebug,才能使用Xdebug。

  zend studio使用Xdebug调试PHP步骤一

  打开zend studio7,选择菜单Project->Properties,然后在弹出界面中选择左侧PHP Debug选项,如图

使用zend studio配置Xdebug调试PHP教程

 

 

zend studio 8 相应的图为:

 

使用zend studio配置Xdebug调试PHP教程

 

  勾选 Enable project specific settings选项,并选择PHP Debugger选项中的Xdebug选项,最后点击确定即可。

  说明:在使用zend studio调试PHP时,有时会出现一个问题,即zend studio调试PHP文件时没有使用Xdebug进行调试,可通过点击左侧上方的项目窗口选择具体的项目或项目文件,右击选择Properties选项进行配置,界面和上图一样。

  在zend studio中使用Xdebug调试PHP源码

  使用zend studio调试PHP,主要通过Debug As菜单,共有三种选择PHP Script、PHP Web Page、PHP Unit Test,此处选择PHP Web Page,由于可能存在同一PHP文件之前使用zend studio调试PHP时并没有选择使用Xdebug,需要清除旧的调试文件,可以通过Debug Configurations菜单清除上述三种zend studio调试方式中的文件,此处选择的是PHP Web Page,所以只要将此项中的文件清除即可。

  Debug Configurations可通过三种方式进入:1、右击需要调试的PHP文件,选择Debug As或者打开调试的PHP文件;2、选择菜单栏上Run菜单下的Debug As进入;3、点击菜单栏Run菜单下方小蜘蛛图标旁的向下箭头选择Debug Configurations。

  Debug Configurations配置完毕后,可打开需要使用zend studio调试的PHP文件选择Debug As中的PHP Web Page选项,核对好Launch Url后点击Ok即可调试,Xdebug在zend studio中调试PHP文件的画面如图

 

 使用zend studio配置Xdebug调试PHP教程

 

  如图你可以通过单步调试(F5)对PHP文件进行调试,只要Xdebug配置正确,在调试代码窗口中会出现选中的淡绿色背景代码,否则单步调试(F5)功能是失效的。

  最后你可以在D:\PHPWeb\xdebug\traceD:\PHPWeb\xdebug\profiler目录下看到zend studio调试PHP文件时Xdebug输出的调试信息文件cachegrind.out.*和trace.*.xt。

  至此使用zend studio配置Xdebug调试PHP源码的基础教程就介绍完了,今后还将介绍更多zend studio调试PHP源码的PHP教程。

 

 

 

 

摘自:http://www.leapsoul.cn/?p=958

 

 

 

 

 

 

 

 

 

 

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

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months 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)

Detailed explanation of C++ function debugging: How to debug problems in multi-threaded functions? Detailed explanation of C++ function debugging: How to debug problems in multi-threaded functions? May 02, 2024 pm 04:15 PM

C++ multi-thread debugging can use GDB: 1. Enable debugging information compilation; 2. Set breakpoints; 3. Use infothreads to view threads; 4. Use thread to switch threads; 5. Use next, stepi, and locals to debug. Actual case debugging deadlock: 1. Use threadapplyallbt to print the stack; 2. Check the thread status; 3. Single-step the main thread; 4. Use condition variables to coordinate access to solve the deadlock.

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

How to use LeakSanitizer to debug C++ memory leaks? How to use LeakSanitizer to debug C++ memory leaks? Jun 02, 2024 pm 09:46 PM

How to use LeakSanitizer to debug C++ memory leaks? Install LeakSanitizer. Enable LeakSanitizer via compile flag. Run the application and analyze the LeakSanitizer report. Identify memory allocation types and allocation locations. Fix memory leaks and ensure all dynamically allocated memory is released.

Shortcut to golang function debugging and analysis Shortcut to golang function debugging and analysis May 06, 2024 pm 10:42 PM

This article introduces shortcuts for Go function debugging and analysis, including: built-in debugger dlv, which is used to pause execution, check variables, and set breakpoints. Logging, use the log package to record messages and view them during debugging. The performance analysis tool pprof generates call graphs and analyzes performance, and uses gotoolpprof to analyze data. Practical case: Analyze memory leaks through pprof and generate a call graph to display the functions that cause leaks.

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

How to debug PHP asynchronous code How to debug PHP asynchronous code May 31, 2024 am 09:08 AM

Tools for debugging PHP asynchronous code include: Psalm: a static analysis tool that can find potential errors. ParallelLint: A tool that inspects asynchronous code and provides recommendations. Xdebug: An extension for debugging PHP applications by enabling a session and stepping through the code. Other tips include using logging, assertions, running code locally, and writing unit tests.

PHP Debugging Errors: A Guide to Common Mistakes PHP Debugging Errors: A Guide to Common Mistakes Jun 05, 2024 pm 03:18 PM

Common PHP debugging errors include: Syntax errors: Check the code syntax to make sure there are no errors. Undefined variable: Before using a variable, make sure it is initialized and assigned a value. Missing semicolons: Add semicolons to all code blocks. Function is undefined: Check that the function name is spelled correctly and make sure the correct file or PHP extension is loaded.

What is Bitget Launchpool? How to use Bitget Launchpool? What is Bitget Launchpool? How to use Bitget Launchpool? Jun 07, 2024 pm 12:06 PM

BitgetLaunchpool is a dynamic platform designed for all cryptocurrency enthusiasts. BitgetLaunchpool stands out with its unique offering. Here, you can stake your tokens to unlock more rewards, including airdrops, high returns, and a generous prize pool exclusive to early participants. What is BitgetLaunchpool? BitgetLaunchpool is a cryptocurrency platform where tokens can be staked and earned with user-friendly terms and conditions. By investing BGB or other tokens in Launchpool, users have the opportunity to receive free airdrops, earnings and participate in generous bonus pools. The income from pledged assets is calculated within T+1 hours, and the rewards are based on

See all articles