search
HomeBackend DevelopmentPHP Tutorial [分享]怎么使用XDebug+NetBeans IDE 搭建PHP开发调试环境

[分享]如何使用XDebug+NetBeans IDE 搭建PHP开发调试环境
初学PHP开发,由于一直未能搭建一个可以Remote Debugging的环境,导致开发效率异常低下。

被MS惯坏了的我,显然无法习惯这种记事本+IE Explorer的开发模式。因此决定搭建一个可以进行Debug的PHP开发环境。

阅览多方资料后我决定使用NB+XDebug来搭建环境。由于搭建环境之步骤稍显繁琐,特此记录以备忘。 

 

1,首先去下载NetBeans,目前最新版是NetBeans 7.0,注意选哪个带有PHP插件的。

为了方便起见,我下载的是包含了Full Features的版本。

给个链接:

http://netbeans.org/downloads/start.html?platform=windows&lang=zh_CN&option=all

 

2,下载你需要的XDebug的版本。

2.1 准备工作

在此之前确保你装上了xampp, 也就是一个PHP和Apache,MySql,Perl的整合套件。目前最新版本是1.7.4 Final。这里也给出一个下载链接

http://www.newhua.com/soft/50127.htm

 

2.2 测试XAMPP安装情况

       如果一切就绪,浏览器输入http://localhost:80看是否正确安装Apache,PHP。

       可以使用phpInfo()查看PHP特性安装情况。

2.3 安装XDebug

XDebug只是PHP的一个Extension。去XDebug的官网下载即可。

这里也给出一个下载地址

http://xdebug.org/download.php

 

注意的是,这里版本众多,如何选择需要再次开启浏览器,查看phpInfo函数的输出。根据PHP版本,PHP Build环境(VC6 or VC9),是否是Thread safe(TS)来选择一个合适的XDebug的版本即可。

 

3,XDebug的配置。

       修改PHP.ini 的XDEBUG Section。

       需要确保开启几个配置选项,一般来说建议开启如下几个选项。

       zend_extension=”XDebug的路径”

例如”zend_extension=/php/ext/php_xdebug-2.1.0-5.2-vc6.dll”

      xdebug.remote_enable=on
      xdebug.remote_handler=dbgp
      xdebug.remote_host=localhost
      xdebug.remote_port=9000   //默认是9000 建议该一下

然后重启Apache的服务。在phpInfo中查看XDebug Section下的配置项。

 

       说明, 貌似XAMPP中的PHP.ini已经整合了XDebug只不过注释起来了。我们所要做的就是去掉注释即可。

4,NetBeans中Debug。

       进入NetBeans,新建一个PHP项目,编写PHP代码。

       然后使用”调试”菜单下的设置断点,步入(Step into), 步过(Step over)等MS的IDE常见的菜单功能项。

       断点断住之后,你还能看到诸如Watch,Local等查看变量值的Window。是不是感觉很过瘾,从此开发PHP程序就可以告别简单的记事本+浏览器模式。拥有一个足以媲美VS开发环境的PHP IDE。更重要的是,这一系列工具都是免费的。

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
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.