8.14.2006

Installing PHPEclipse on Eclipse including Debugging Engine

To write PHP codes, you do not need to have a sophisticated IDE or program that helps you. Because PHP script language is perhaps one of the easiest script languages in the world. On the other hand, when your project tends to increase in the size and you do not know exactly where it is going, it will be your advantage to use some alternatives IDEs in the market.

One of the best ones is Eclipse. It is easy to use and of course free to develop your PHP codes. On the other hand, you should install the packages that you are required carefully. I spent hours on the internet to find out a very good way of doing that. There are plenty of good resources on the internet. So I thought that I can contribute to those by writing this blog.

Well, first of all I use a PC running on Windows XP, so all the instructions that I give here will depend on it. To start with I use Eclipse 3.1.x (I need to check for the exact version later). Actually I installed WTP-all-in-one-sdk since it includes Eclipse 3.1 along with Web Standards Tools. This package is very useful since you do not need to install the packages you need in web development separately. Of course, you also need to install PHP engine prior to the PHP development. For that I preferred to use PHP 5.1.2. And I used Windows Installation package so that I do not need to extract the zip files required to certain folder that is alternative to Windows Installation package. By the way, I have to tell that I do not use XAMPP that is I installed Apache Server, MYSQL Server and PHP separately.

So far so good, our configuration is as following:
Eclipse 3.1.2
WTP 1.0.2
PHP 5.1.2

The very first thing we need to do is to install PHPEclipse (the version I use is 1.1.8). Well the installation can be done very different ways but I preferred to extract the zip files to Eclipse folder. When I started to use Eclipse I managed to create a "PHP Project" and a few lines of codes of PHP worked fine on the program. However, the real question for me is to use debugging features and this is where all the troubles occur.

Debugging

Well, to do that we need to certain things. We need to install DBG Debugger. The version I used is 2.13.1 and it can be downloaded here:
http://dd.cron.ru/dbg/downloads.php

In that side, you only need to download the modules so you do not need to download listeners. In that zip file find the correct DLL for your version of PHP. For instance I use PHP 5.1.2 so I find the file "php_dbg.dll_5.1.2" and rename it with "php_dbg.dll" and put it under Windows root folder (in my case it was "C:\Windows").

At this point, you need to change some lines in your "PHP.ini" file. It can be found under the Window's root folder. Here are the things you need to do in that file:

Find out the lines starts with "extension_dir" and the change the entire line as following (do not include the codes in brackets):
extension_dir = "c:/windows/" (Here, this is my root folder for windows).

Then, at the end of the file, put the following lines of codes:
[debugger]
extension=php_dbg.dll
debugger.enabled=on
debugger.profiler_enabled=on
debugger.hosts_allow=localhost (host names or IP's that are allowed to use debuggers)
debugger.hosts_deny=ALL
debugger.ports=7869, 10000/16


Save the file and close the file.

Now it is time to test the settings by using Eclipse. Start your Eclipse and create a new PHP Project named "test3". Then create a php file named "debugTest.php" and add the following line of codes in it:


Now to make a blue dots there, go to that line and double click on that area. This indicates a break on the program which we will use in debugging. Now, change the perspective to Debug ("Window > Open Perspective > Debug"). After that, click "Run > Debug.."
In the File tab, change the "Name", "Project", and "File" fields as indicated in the image below:


Then move to "Environment" tab and in "Remote Debug" sub tab, tick "Remote Debug" and write the absolute path of your project to the text field of "Remote Sourcepath". It will look like as this:


Finally, in the "Interpreter" subpart, point the absolute location of where your PHP program's application file is located:


Then Click the "Debug" to run the debugger. If everything goes well (I hope), you will have a screen like that:



As you can see, from now on by using the same approach, you can debug your PHP files by using Eclipse. If you have some problems, you can use the information provided here:
http://www.plog4u.org/index.php/Using_PHPEclipse_:_Installation_:_Installing_the_DBG_Debugger
It is very good resource and deal with some problems that you can have.
That's all. Enjoy your PHP codes in Eclipse.

Hiç yorum yok: