This guide walks you through the necessary steps to configure the Eclipse IDE for PHP debugging. This can be very handy, especially when you’re trying to resolve an issue in a complex PHP application or plug-in.
Things you’ll need
- Eclipse
- Eclipse PHP Development Tools (PDT)
- Xdebug
Quick Overview
For those that are unaware, Eclipse is a very popular IDE for developing in Java. However, Eclipse is much more powerful than that and can in fact easily be used for developing in many other languages including PHP.
Xdebug is a brilliant debugging extension designed for use with PHP. Once configured, Xdebug will allow you to remotely connect to your web server… or in my case connect to my development localhost web server. Rather than using crude echo and logging techniques to debug your PHP code, Xdebug allows you to literally step through and inspect values and function flows in real-time.
If you’ve ever scratched your head at a PHP script and thrown in dozens of echos or logging statements to track the execution path then you’ll really come to appreciate the benefits of using Xdebug.
Configuring Eclipse and Xdebug isn’t difficult. In fact its painless with the correct steps on hand. That’s where this guide comes in. I found myself coming across incomplete or outdated forum posts and stackoverflow questions, so I thought I’d post what worked for me.
If you already have Java and Eclipse installed, then just jump ahead to installing and configuring the PHP Development Tools and Xdebug.
Install Eclipse
This will install ~118 new packages, assuming you’ve not already installed some of them, and will total around 255 MB that need to be downloaded.
- Open a terminal and enter the following command to install Eclipse:
sudo apt-get install eclipse - After the download completes, open Eclipse to confirm that it installed correctly. Leave it open for our next install.
Install PHP Development Tools (PDT)
- If you don’t have Eclipse open at this point, open it up.
- Navigate through the menus to: Help -> Install New Software…
- You will be prompted with a new window asking you to select a site or enter the location of a site. You should be able to drop down the list of sites and find one labeled “–All Available Sites–”. Select this option and wait for the list below to populate.
- Scroll through the list until you find a category labeled “Programming Languages” and click the arrow to expand this list.
- Continue to scroll through the Programming languages until you find a item labeled “PHP Development Tools (PDT) SDK Feature” and check the box to the left.
- Click Next and continue throw the installation. You’ll have to select that you agree to the terms of installing this software.
- After the installation has completed, you will be asked to restart Eclipse to apply changes. Go ahead and restart Eclipse, then move on to the next install.
Install XDebug
- Open a terminal and enter the following command to install Xdebug:
sudo apt-get install php5-xdebug - After installation completes, there are a couple of files that need to be configured. If you copy and paste the commands below, make sure to check that the quotes that are copied over are regular quotation characters, as they may cause problems if they are not.
-
sudo gedit /etc/php5/conf.d/*xdebug.ini
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “localhost”
xdebug.remote_port = 9000 -
sudo gedit /etc/php5/apache2/php.ini
Scroll to the bottom and add:
zend_extension=/usr/lib/php5/20100525/xdebug.so
-
sudo gedit /etc/php5/conf.d/*xdebug.ini
- Restart your Apache server so that the new PHP configuration settings are loaded.
sudo /etc/init.d/apache2 restart
- Confirm that your Xdebug installation was successfully loaded by creating a simple PHP file called “phpinfo.php” and placing it in the public root of your Apache web server. Be sure to include the following in your file, save it then navigate to it in your browser:
<?php phpinfo(); ?>
- After loading the php info page, search for “xdebug”. If you find it listed, then you have successfully installed and configured Xdebug. If not, check back over the steps listed above or consult Google.
相关推荐
ubuntu 下eclipse CDT搭建交叉编译开发环境
ubuntu_eclipse启动设置,jdk环境变量,其他设置
Ubuntu安装eclipse.txt
本文主要是在ubuntu 16.04环境下,如何安装 eclipse。
解决ubuntu macbuntu eclipse 没有菜单栏.txt
详细介绍Ubuntu环境下安装Eclipse有截图
介绍ubuntu下opencv的eclipse工程配置
Ubuntu下Eclipse中文乱码解决.docx
ubuntu eclipseIDE(开发环境)ubuntu eclipseIDE(开发环境)ubuntu eclipseIDE(开发环境)ubuntu eclipseIDE(开发环境)
简单有效的配置Ubuntu下Eclipse C&C++项目的开发编译环境,照着文档一步一步配置,让你少走弯路。
Ubuntu中eclipse的安装
Ubuntu下使用Eclipse开发CC++
解决 Ubuntu Eclipse 代码浮层黑色背景问题
Ubuntu下eclipse环境搭建,开发Android需要用的哦,简单介绍
phpdebug工具,已经编译,2.*版本
Ubuntu下 JDK 和 ECLIPSE的安装,亲测可用,解压命令什么我就不说了。
ubuntu eclipse qt插件 用于搭建ubuntu环境下的界面开发, QT具有良好的平台移植性
在ubuntu_linux下安装eclipse以及运行c++程序的安装步骤