Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/51/12486951/html/kurinchilamp/wp-content/plugins/statpress-reloaded/statpress.php on line 1786
Kurinchi Blogger Scribbles … » Blog Archive » How to debug PHP programs with XDebug and Notepad++?

How to debug PHP programs with XDebug and Notepad++?

XDebug provides a lot of useful information to a PHP programmer to debug code thus saving time and increasing efficiency.

As a first step, check the version of PHP you are running by creating phpinfo() in a file.

When the program is executed you will see a line of text showing the version of PHP you are using


This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Now that we know the version of PHP we are using, we can download the relevant xdebug version to to debug PHP programs with Notepad++

We will setup Notepad++ with xdebug and dbgp plugin.

Download xdebug.org from http://xdebug.org/download.php. There is a custom installation steps link on xdebug home page that will help you identify which version of xdebug you need to download based on the information presented in phpinfo.

We will be downloading php_xdebug-2.1.2-5.2-vc6.dll to suite our php version in this example.

Copy the dll file into the extensions folder C:\wamp\bin\php\ext (or to a path that is accessible to webserver) so that the program gets identified by PHP engine.

Add the following set of lines under “Module settings” in php.ini (or at the bottom of php.ini file)


[xdebug] zend_extension_ts="c:/wamp/php/ext/php_xdebug-2.1.2-5.2-vc6.dll"
xdebug.profiler_output_dir = "c:/wamp/tmp/xdebug"
xdebug.remote_host=127.0.0.1
xdebug.extended_info=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.idekey=xdebug

Restart apache web server so that the changes can be recognized.

Open the phpinfo page again. Now you can see Xdebug is successfully configured with php engine and it is ready for application profiling and remote debugging.


This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

Now we need to download dbgp plugin for Notepad++. Goto sourceforge for DBGP plugin download. http://sourceforge.net/projects/npp-plugins/files/DBGP%20Plugin/

After download put the dll file into Notepad++ plugins folder C:\Program Files\Notepad++\plugins

Close and reopen Notepad++ and you can see DBGP plugin under “Plugins” option.

Select Plugins > DBGp > Config and set the following
Remote Server IP: 127.0.0.1
IDE KEY: xdebug
Remote Path: c:\wamp\www
Local Path: c:\wamp\www
Check the boxes for “Refresh local context on every step” and “Refresh global context on every step”.

To debug PHP programs, now write a program say mytest.php in the localhost and save it.

<?php
echo ”
XDebug – First program”;

for($i=0; $i{
echo “*”;
// Create a debug point after this line
if(($i % 10) == 0) echo “$”;
}
?>

Open the program in Notepad++. Click “Plugins” > “DBGp”. DBGp trace window will open in the bottom of Notepad++.

Go to a line in the php program you just wrote where you want to debug and click the red round icon on DBGp panel to set the breakpoint.

Now execute the php program on the browser http://localhost/mytest.php and Notepad++ will start to blink indicating that the trace had started.

Share

Written by kurinchilamp


Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
How to configure Zend Framework on an Apache server in a PLESK environment?

First, download the Zend framework and unzip the file contents to a location. At the time of the writing ZendFramework-1.11.12...

Close