Configuring Xdebug,Eclipse PDT,Xampp in Linux

After a large battle in figuring out the debugging of a PHP Application.We have come with a solution.

Here whats the step we have followed.

Step 1:

Download the EclipsePDT.

Step 2:

Download the XAMPP Server for linux and download its corresponding development version too.

Download the Xdebug Source.

Step 3:
Once all have done,extract XAMPP package to /opt by using the ‘Terminal’.

ckuser@ckuser-desktop:~$ sudo tar xvzf xampp1.7.2.tar.gz -C /opt

It will take a minute to extract all your files.

Once its done.Start the server by the command.

ckuser@ckuser-desktop:~$ sudo /opt/lampp/lampp start.

You should see the xampp server page is up in the browser and click on the ‘phpinfo’ on the left hand side of the xampp screen.

You will see the PHP Version and Location of your ‘php.ini’ file.

Make a note of that.It will need for a future use.

Step 4:
Then stop the server,

ckuser@ckuser-desktop:~$ sudo /opt/lampp/lampp stop.

Now give the permission to /opt/lampp to extract the package directly.

ckuser@ckuser-desktop:~$ sudo chmod -R 777 /opt/lampp

Now open the devlopment package of xampp,in that you will see ‘many directories like ‘build’,’include’ and so on.Select all that directories and extract to /opt/lampp.

Once its done,

Now open the Xdebug package,extract to /opt/lampp/bin.

Give full permission to Xdebug folder.

ckuser@ckuser-desktop:~$ sudo chmod -R 777 /opt/lampp/bin/name of the xdebug directory.

Now change the permission to /opt/lampp

ckuser@ckuser-desktop:~$ sudo chmod -R 755 /opt/lampp

And then create a workspace directory in root directory of xampp.

ckuser@ckuser-desktop:~$ sudo mkdir /opt/lampp/htdocs/any name you wish.

Give full permission to the workspace directory.

Step 5:

Start the server again.

ckuser@ckuser-desktop:~$ sudo /opt/lampp/lampp start.

Open your ‘php.ini’ file located in /opt/lampp/etc/php.ini

ckuser@ckuser-desktop:~$ sudo gedit /opt/lampp/etc/php.ini

it will open up in the ‘gedit’ file.

go to the last line of the ‘php.ini’ file,add the below code in that file.

[Zend Debug]
zend_extension=/opt/lampp/bin/xdebug-2.0.5/modules/xdebug.so

xdebug.remote_enable=on

xdebug.remote_host=localhost

xdebug.remote_port=9000

save and close the file.

For getting a xdebug.so compiled for your version of PHP.Follow these steps

ckuser@ckuser-desktop:~$ cd /opt/lampp/bin/xdebug-2.0.5
ckuser@ckuser-desktop:~$ sudo /opt/lampp/bin/phpize

it will come up the version then type the next command

ckuser@ckuser-desktop:~$ ./configure --with-php-config=/opt/lampp/bin/php-config

Then ‘make’ the ‘so’ file.

for that,

ckuser@ckuser-desktop:~$ sudo make

then for ‘testing the ‘so’ file.

ckuser@ckuser-desktop:~$ sudo make test

it should come up with a message ‘Build Completed’.

Now if you navigate to the xdebug–>modules directory, you will find the ‘xdebug.so’ file.

Now restart the server

ckuser@ckuser-desktop:~$ sudo /opt/lampp/lampp restart

Thats all will done.

Configure the rest of part in eclipse,it will work fine.

Thanks for all my friends and my special one.

Advertisements

Configure Eclipse PDT with X-Debug and XAMPP

In my Past days, i was trying to figure out the setup of Eclipse PDT with X-Debug and XAMPP for debugging a PHP Application..From my friends help,at last i configured it properly and make it up and running.

Here are the steps for the setting up the configuration.

Step 1:

Download the Eclipse PDT.

Step 2:

Download the XAMPP 1.7.2 .

Step 3:

Install the Eclipse and XAMPP and Check that Eclipse and XAMPP Server is up and running.

Step 4:

To make sure the XAMPP Server is running.Open your web browser and type in the URL(“http://localhost” without quotes). And you should see the XAMPP Start up Page.

Step 5:

Now stop the XAMPP Server.Navigate to the XAMPP installation directory. And you will find the ‘htdocs’.Create a PHP File inside that directory.

Thats looks like this

<? php

echo phpinfo();

?>

Save the File with any name you wish to have(For example:sample.php).And then start the XAMPP Server.

Then open your browser and start typing in the URL(“http://localhost/sample.php&#8221;)

You will see all your information about the XAMPP Server.

There you will have particular information that where is your ‘php.ini’ is located.

Step 6:

Stop your XAMPP Server, navigate to the ‘php.ini’  file directory then open the file in notepad .

Go to last line of the ‘php.ini’ file and add the lines that shown just below

[Zend Debug]
zend_extension=C:\xampp\php\ext\php_xdebug.dll
zend_debugger.allow_hosts=127.0.0.1/32, 10.0.1.135/16
zend_debugger.expose_remotely=always

Now save the file and close it.Now Start the XAMPP Server again.

Step 7:

Now open your Eclipse.

Create a ‘New PHP Project’ and Create a New File in that with any name you wish to have(For Example ‘test.php’)

In that ‘test.php’ have a small php code to test it.

For example

<?php

echo “any text you wish”;

?>

Save the file.

Step 8:

Now ,we are going to configure the debugging part.

Select your project directory in eclipse and then click on ‘Window–>Preferences’

In that expand the ‘General’ tab you will see ‘Web Browser’ click on that and then select your web browser you want your output to be displayed.

Then Apply the Setting.

Navigate to the ‘PHP’ Tab and expand it on the left hand side of the ‘Preference’ window.

You will see the ‘Debug’ tab’ and click on that.

In that screen,

Leave the below thing as Default

PHP Debugger is Zend Debugger and click on Configure in that then you will have two servers that will be listed over there.Click on XDebug and select ‘configure’ you will have ‘Access remote session(JIT)’ should be ‘localhost’ . select that and click ‘OK’.

Sever is Default PHP Web Server

then  below that click on ‘PHP Executable s’.Click on ‘Search’ and locate where the XAMPP Server is installed and then click ‘OK’.

After a few minute it will show you one ‘PHP Executable’ listed over there.

Select that click on ‘Edit’ .

There you will have PHP ini File (Optional)

Click on ‘Browse’ in that navigate to ‘XAMPP Server installation Directory and there you will find ‘PHP’ Directory in that select ‘php.ini’ and then click ‘OK’ and then below that you will ‘PHP Debugger’ as ‘XDebug’.

Then apply the Setting and then click ‘OK’.

And then click ‘OK’ to apply the over all setting that you have made to it.

Now fix the breakpoint in a file and ‘Debug’ the File and see the output.

Its all configured properly.

Thanks for all my friends to share their ideas to fix up this.