[分享]怎么使用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。更重要的是,这一系列工具都是免费的。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.
