<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.giustetti.net/wiki/index.php?action=history&amp;feed=atom&amp;title=En%2Fxdebug</id>
	<title>En/xdebug - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.giustetti.net/wiki/index.php?action=history&amp;feed=atom&amp;title=En%2Fxdebug"/>
	<link rel="alternate" type="text/html" href="http://www.giustetti.net/wiki/index.php?title=En/xdebug&amp;action=history"/>
	<updated>2026-04-20T12:57:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>http://www.giustetti.net/wiki/index.php?title=En/xdebug&amp;diff=1215&amp;oldid=prev</id>
		<title>Wikiuser at 13:58, 21 March 2022</title>
		<link rel="alternate" type="text/html" href="http://www.giustetti.net/wiki/index.php?title=En/xdebug&amp;diff=1215&amp;oldid=prev"/>
		<updated>2022-03-21T13:58:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:58, 21 March 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Wikiuser</name></author>
	</entry>
	<entry>
		<id>http://www.giustetti.net/wiki/index.php?title=En/xdebug&amp;diff=594&amp;oldid=prev</id>
		<title>Wikiuser: Added an article about Xdebug 2 and PHP code debugging</title>
		<link rel="alternate" type="text/html" href="http://www.giustetti.net/wiki/index.php?title=En/xdebug&amp;diff=594&amp;oldid=prev"/>
		<updated>2016-02-09T23:11:40Z</updated>

		<summary type="html">&lt;p&gt;Added an article about Xdebug 2 and PHP code debugging&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{header_en|title=Installing, configuring and using Xdebug| keyword={{Template:keyword_en_php}}| description=Using Xdebug to debug PHP source code | link_page=xdebug}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
'''PHP''' is a mature programming language maintained by an active community for the past two decades. In spite of its widespread use for dynamic web site development, PHP lacks some features adopted by lesser known languages for quite some time. An evident lack consisting in the absence of a '''default integrated debugger'''. The term '''Debugging''' summarizes the analysis and bug correction activities that occupy a considerable part of every developer working time. Availability of powerful advanced easy to configure and use tools grants an increased productivity and evident gains for both developers and end users.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
'''PHP''' release '''5.6''' introduced a largely anticipated new feature: '''[http://phpdbg.com/docs PHPDbg]''' the integrated debugger. Given the short age of the release and the large diffusion earlier ones still have in production environments, I'll present some available alternatives to PHPDbg:&lt;br /&gt;
* [http://pecl.php.net/package/apd Advanced PHP Debugger]&lt;br /&gt;
: A first attempt at a PHP debugger designed as a '''Zend''' engine extension. '''ADP development seems to have met a stop long ago''': the last official release dates back to 2004.&lt;br /&gt;
* [http://www.php-debugger.com/dbg/ DBG]&lt;br /&gt;
: A commercial product. A free version of DBG with reduced functionality and no support is available for download. The commercial version works with all of modern PHP releases up to 5.5 while the open source one, whose latest release dates back to 2007, is restricted to PHP 5.2.&lt;br /&gt;
* [https://xdebug.org/ Xdebug]&lt;br /&gt;
: Seems to be the only software still actively developed. The next major release 2.4 was announced in January 2016. Xdebug is a free and open source product whose source code can be freely downloaded, studied, modified and redistributed.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
In this paper I'll try to explain you how to '''install, configure and use Xdebug on a Linux host running Slackware Linux'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Xdebug ==&lt;br /&gt;
&lt;br /&gt;
'''Xdebug''' is designed as a plug-in module that extends the PHP Zend engine adding useful functionality for debugging and profiling of source code. Xdebug uses the standard '''DBGp''' debugging protocol and can:&lt;br /&gt;
* Dump the flow of function calls and stack traces.&lt;br /&gt;
* Dump all of the parameter values passed to functions.&lt;br /&gt;
* Monitor memory usage.&lt;br /&gt;
* Execute interactive debugging of source code when used together with a graphical debugging program.&lt;br /&gt;
&lt;br /&gt;
=== Installing ===&lt;br /&gt;
Xdebug is distributed as a '''PECL''' (PHP Extension Community Library) extension, but it is still possible to build and install it as a '''standard Linux package'''. I chose the latter method even if it requires some extra work because it allows to remove, reinstall and update the software recurring to standard operating system commands. A step by step procedure to install Xdebug from source code is described below. All the steps other than file download should be executed by an user with administrator privileges as '''root'''.&lt;br /&gt;
&lt;br /&gt;
* Download the source code archive from [https://xdebug.org/download.php the Xdebug official web site] into a directory of choice. I'll use '''/tmp'''.&lt;br /&gt;
* Download the [https://slackbuilds.org/repository/14.1/development/xdebug/?search=xdebug SlackBuild] file used to build a '''Slackware Linux''' package in a directory of your choice. I'll use '''/tmp''' again.&lt;br /&gt;
* Decompress the '''xdebug.tar.gz''' archive containing the '''xdebug.SlackBuild''' build script:&lt;br /&gt;
   root@darkstar_5:/tmp# '''tar''' ''-zxf'' xdebug.tar.gz &lt;br /&gt;
   root@darkstar_5:/tmp# '''ls''' ''-la'' xdebug&lt;br /&gt;
   total 36&lt;br /&gt;
   drwxr-xr-x  2 1016 users 4096 Dec 25  2014 .&lt;br /&gt;
   drwxrwxrwt 15 root root  4096 Feb  2 18:53 ..&lt;br /&gt;
   -rw-r--r--  1 1016 users  974 Nov 26  2013 README&lt;br /&gt;
   -rw-r--r--  1 1016 users  507 Nov 26  2013 doinst.sh&lt;br /&gt;
   -rw-r--r--  1 1016 users 1093 Nov 26  2013 slack-desc&lt;br /&gt;
   -rwxr-xr-x  1 1016 users 4157 Dec 25  2014 xdebug.SlackBuild&lt;br /&gt;
   -rw-r--r--  1 1016 users  266 Dec 25  2014 xdebug.info&lt;br /&gt;
   -rw-r--r--  1 1016 users 1270 Nov 26  2013 xdebug.ini&lt;br /&gt;
* Edit the script assigning the right release number to the VERSION variable. While I write these lines Xdebug 2.4 has not been released yet therefore I'll use release 2.3.3. Load the '''xdebug.SlackBuild''' file in your text editor of choice; mine is '''vim''':&lt;br /&gt;
   root@darkstar_5:/tmp# '''vim''' xdebug/xdebug.SlackBuild&lt;br /&gt;
Search for variable '''VERSION''' and update the assigned value to match the Xdebug version string:&lt;br /&gt;
   &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
   PRGNAM=xdebug&lt;br /&gt;
   VERSION=${VERSION:-2.2.6}&lt;br /&gt;
   BUILD=${BUILD:-1}&lt;br /&gt;
   &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Should became:&lt;br /&gt;
   &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
   PRGNAM=xdebug&lt;br /&gt;
   VERSION=${VERSION:-2.3.3}&lt;br /&gt;
   BUILD=${BUILD:-1}&lt;br /&gt;
   &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The updated script will suffice to build a working package, but if you wish to produce a package in the '''txz''' format, the last one adopted by Slackware, instead of the old and usual '''tgz''' you'll have to modify one more line: the one that invokes the package generation command.&lt;br /&gt;
   &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
   cd $PKG&lt;br /&gt;
   /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}&lt;br /&gt;
   &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Should be updated in:&lt;br /&gt;
   &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
   cd $PKG&lt;br /&gt;
   /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}&lt;br /&gt;
   &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Once all of the desired SlackBuild script lines are updated you are ready to run the script thus starting the build procedure.&lt;br /&gt;
* Copy the source code tarball into the directory containing script '''xdebug.SlackBuild''':&lt;br /&gt;
   root@darkstar_5:/tmp# '''cp''' xdebug-2.3.3.tgz xdebug&lt;br /&gt;
* Run the script:&lt;br /&gt;
   root@darkstar_5:/tmp# '''cd''' xdebug&lt;br /&gt;
   root@darkstar_5:/tmp/xdebug# '''sh''' ./xdebug.SlackBuild &lt;br /&gt;
The script will execute each step in autonomy calling the '''/usr/bin/phpize''' command, configuring the source code and compiling it to produce a working package in directory '''/tmp'''. The produced binaries include both the Xdebug server layer and the client one '''debugclient'''. Invoke the '''installpkg''' command to install the newly generated package as in the example below:&lt;br /&gt;
   root@darkstar_5:/tmp/xdebug# '''cd''' /tmp&lt;br /&gt;
   root@darkstar_5:/tmp# '''installpkg''' xdebug-2.3.3-x86_64-1_SBo.txz&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
The package is successfully installed. It is time to configure PHP in order for Xdebug to be correctly detected and loaded by the Zend engine. A line for the newly added extension and its parameters should be added in the '''/etc/httpd/php.ini''' configuration file. The line should include the exact location of the xdebug.so binary and its full path: '''/usr/lib64/php/extensions/xdebug.so''' for a 64 bit Slackware Linux system.&lt;br /&gt;
   ; StudioSG - Enable xdebug&lt;br /&gt;
   zend_extension=&amp;quot;/usr/lib64/php/extensions/xdebug.so&amp;quot;&lt;br /&gt;
   ; StudioSG - Limit recursive calls to 10000 (Avoids starvation)&lt;br /&gt;
   xdebug.max_nesting_level = 10000&lt;br /&gt;
   ; StudioSG - Xdebug configuration end&lt;br /&gt;
In addition to the file location I set an upper limit to the number of times a script can be called while in a loop in order to avoid resource starvation and the resulting server issues.&lt;br /&gt;
&lt;br /&gt;
The configuration is now concluded restart the web server to be able to use Xdebug. To check that the extension is loaded and running write a PHP page that calls function '''phpinfo()''' and load it in a web browser. An simple example of such a page is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''phpinfo.php'': The page dumps the PHP and Zend engine configuration.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;?php phpinfo(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If everything works fine a Xdebug dedicated configuration section will appear and its content will look similar to the example below:&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width: 60%;&amp;quot;&lt;br /&gt;
|+ '''xdebug'''&lt;br /&gt;
|- style=&amp;quot;background-color:#9999CC;&amp;quot;&lt;br /&gt;
! xdebug support !! enabled&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#CCCCFF;&amp;quot; | Version || style=&amp;quot;background-color:#CCCCCC; text-align:right;&amp;quot; | 2.3.3&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#CCCCFF;&amp;quot; | IDE Key || style=&amp;quot;background-color:#CCCCCC; text-align:right;&amp;quot; | root&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There is yet another way to test for the extension to be successfully loaded and running: Invoke the '''php''' command to list all of its active modules:&lt;br /&gt;
&lt;br /&gt;
   root@darkstar_5:~# '''php''' ''-m''&lt;br /&gt;
   [PHP Modules]&lt;br /&gt;
   bcmath&lt;br /&gt;
   bz2&lt;br /&gt;
   calendar&lt;br /&gt;
   Core&lt;br /&gt;
   ctype&lt;br /&gt;
   curl&lt;br /&gt;
   date&lt;br /&gt;
   dba&lt;br /&gt;
   dom&lt;br /&gt;
   enchant&lt;br /&gt;
   ereg&lt;br /&gt;
   exif&lt;br /&gt;
   fileinfo&lt;br /&gt;
   filter&lt;br /&gt;
   ftp&lt;br /&gt;
   gd&lt;br /&gt;
   gettext&lt;br /&gt;
   gmp&lt;br /&gt;
   hash&lt;br /&gt;
   iconv&lt;br /&gt;
   imap&lt;br /&gt;
   intl&lt;br /&gt;
   json&lt;br /&gt;
   ldap&lt;br /&gt;
   libxml&lt;br /&gt;
   mbstring&lt;br /&gt;
   mcrypt&lt;br /&gt;
   mysql&lt;br /&gt;
   mysqli&lt;br /&gt;
   mysqlnd&lt;br /&gt;
   openssl&lt;br /&gt;
   pcntl&lt;br /&gt;
   pcre&lt;br /&gt;
   PDO&lt;br /&gt;
   pdo_mysql&lt;br /&gt;
   pdo_sqlite&lt;br /&gt;
   Phar&lt;br /&gt;
   posix&lt;br /&gt;
   pspell&lt;br /&gt;
   Reflection&lt;br /&gt;
   session&lt;br /&gt;
   shmop&lt;br /&gt;
   SimpleXML&lt;br /&gt;
   snmp&lt;br /&gt;
   soap&lt;br /&gt;
   sockets&lt;br /&gt;
   SPL&lt;br /&gt;
   sqlite3&lt;br /&gt;
   standard&lt;br /&gt;
   sysvmsg&lt;br /&gt;
   sysvsem&lt;br /&gt;
   sysvshm&lt;br /&gt;
   tokenizer&lt;br /&gt;
   wddx&lt;br /&gt;
   '''xdebug'''&lt;br /&gt;
   xml&lt;br /&gt;
   xmlreader&lt;br /&gt;
   xmlwriter&lt;br /&gt;
   xsl&lt;br /&gt;
   zip&lt;br /&gt;
   zlib&lt;br /&gt;
   &lt;br /&gt;
   [Zend Modules]&lt;br /&gt;
   '''Xdebug'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Integrating Xdebug with Third Party Editors / IDEs ==&lt;br /&gt;
&lt;br /&gt;
A base Xdebug installation may not seem much help for developers as it requires to update the source code adding extra lines to have PHP dump useful information when debugging errors. It would probably be preferable to execute unaltered code step by step: a common debugger feature available for many other programming languages. Actually Xdebug does export all of the needed information to follow code flow during execution, but it does not provide a standard environment to view it. The main advantage of Xdebug consists of the use of a standard debugging protocol, which allows to '''interface the debugging service to a multitude of third party developer tools''' through specific modules and plug-ins. It is therefore possible to add code debug and profiling functionality to your development environment of choice.&lt;br /&gt;
&lt;br /&gt;
A list of supported clients that can be used to check and debug remote code is available in the [https://xdebug.org/docs/remote Xdebug web site] pages. The list includes plug-ins for '''[https://www.eclipse.org Eclipse]''', '''[https://www.kdevelop.org Kdevelop]''', '''[http://php.netbeans.org NetBeans]''' and many more. Moreover a quick search of the web will provide extensions for Firefox / Seamonkey, Chrome and many other web browsers. If you'd prefer a stand alone program take a look at [http://robertbasic.com/blog/pugdebug-1-0-0 Pugdebug] which is covered by an open source license and whose [https://github.com/robertbasic/pugdebug source code] is freely available.&lt;br /&gt;
&lt;br /&gt;
Some '''modules to extend text editor''' exist too. Not so striking graphically, but '''really helpful for debugging servers''' where, because of security or performance concerns, a graphical interface is often unavailable and command line tools represent your only choice. The '''Vim''' extension proved to be really useful whenever there was no way to use a graphic environment. Vim is one of the more widespread adopted text editors in Linux / Unix because of its versatility and nearly infinite feature list.&lt;br /&gt;
&lt;br /&gt;
=== Xdebug - Vdebug Integration ===&lt;br /&gt;
Two plug-ins exist to integrate Xdebug and Vim. I'll use '''[https://github.com/joonty/vdebug Vdebug]''': the newer one which essentially replaced the old '''Debugger'''. Vdebug is a multi-language debug client able to interface any debugger or language that uses the '''DBGP''' protocol. Among others:&lt;br /&gt;
* NodeJS&lt;br /&gt;
* Perl&lt;br /&gt;
* PHP&lt;br /&gt;
* Python&lt;br /&gt;
* Ruby&lt;br /&gt;
* Tcl&lt;br /&gt;
'''Vdebug requires a working Python language interpreter to function properly'''.&lt;br /&gt;
&lt;br /&gt;
I'll describe the procedure to install Vdebug on a computer running '''Slackware Linux 14.1''' below.&lt;br /&gt;
* Download the latest available source code archive from the [https://github.com/joonty/vdebug Vdebug git repository] into a local directory. For example: '''/tmp'''.&lt;br /&gt;
* Create directories '''doc''', '''plugin''', '''syntax''' and '''tests''' in the Vim root directory in your user home. Vim files are usually located in '''~/.vim''' or '''$HOME/.vim''':&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''mkdir''' ~/.vim/doc&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''mkdir''' ~/.vim/plugin&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''mkdir''' ~/.vim/syntax&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''mkdir''' ~/.vim/tests&lt;br /&gt;
* Populate the newly created directories with files extracted from the install archive package (Please note: The actual file list varies between Vdebug releases therefore the one provided below could differ from yours).&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''ls''' ''-la'' ~/.vim/*&lt;br /&gt;
   /home/sviluppo/.vim/doc:&lt;br /&gt;
   total 68&lt;br /&gt;
   drwxr-xr-x 2 sviluppo users  4096 Dec  5  2014 .&lt;br /&gt;
   drwxr-xr-x 6 sviluppo users  4096 Dec  5  2014 ..&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users 56210 May 15  2014 Vdebug.txt&lt;br /&gt;
   -rw-r--r-- 1 sviluppo users  3880 Dec  5  2014 tags&lt;br /&gt;
   &lt;br /&gt;
   /home/sviluppo/.vim/plugin:&lt;br /&gt;
   total 20&lt;br /&gt;
   drwxr-xr-x 3 sviluppo users 4096 Dec  5  2014 .&lt;br /&gt;
   drwxr-xr-x 6 sviluppo users 4096 Dec  5  2014 ..&lt;br /&gt;
   drwxr-xr-x 3 sviluppo users 4096 Feb 20  2014 python&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users 7158 May 15  2014 vdebug.vim&lt;br /&gt;
   &lt;br /&gt;
   /home/sviluppo/.vim/syntax:&lt;br /&gt;
   total 28&lt;br /&gt;
   drwxr-xr-x 2 sviluppo users 4096 Dec  5  2014 .&lt;br /&gt;
   drwxr-xr-x 6 sviluppo users 4096 Dec  5  2014 ..&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  518 Oct 31  2012 debugger_breakpoint.vim&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  541 Oct 31  2012 debugger_log.vim&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  637 Oct 31  2012 debugger_stack.vim&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  720 Oct 31  2012 debugger_status.vim&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users 1574 Nov 11  2013 debugger_watch.vim&lt;br /&gt;
   &lt;br /&gt;
   /home/sviluppo/.vim/tests:&lt;br /&gt;
   total 144&lt;br /&gt;
   drwxr-xr-x 2 sviluppo users  4096 Nov 11  2013 .&lt;br /&gt;
   drwxr-xr-x 6 sviluppo users  4096 Dec  5  2014 ..&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users   299 May  9  2013 helper.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  7376 May  9  2013 test_breakpoint_breakpoint.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users 10691 May  9  2013 test_breakpoint_breakpoint.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  7336 May  9  2013 test_dbgp_api.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  9267 May  9  2013 test_dbgp_api.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  2354 May  9  2013 test_dbgp_connection.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  3821 May  9  2013 test_dbgp_connection.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  5822 May  9  2013 test_dbgp_context_property.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  7104 May  9  2013 test_dbgp_context_property.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  9134 May  9  2013 test_dbgp_response.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users 12156 May  9  2013 test_dbgp_response.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  1349 May  9  2013 test_opts_options.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  3030 May  9  2013 test_opts_options.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  9517 May  9  2013 test_ui_vimui_api.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  4708 Nov 11  2013 test_util_filepath.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users  7186 Nov 11  2013 test_util_filepath.pyc&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users    25 Oct 31  2012 vim.py&lt;br /&gt;
   -rw-rw-r-- 1 sviluppo users   314 May  9  2013 vim.pyc&lt;br /&gt;
&lt;br /&gt;
* Create tags needed by the Vdebug documentation:&lt;br /&gt;
   sviluppo@darkstar_5:~$ '''vim'''&lt;br /&gt;
      :helptags $HOME/.vim/doc&lt;br /&gt;
* Update the '''php.ini''' configuration file adding some lines:&lt;br /&gt;
   ; StudioSG - Add support for the vim debugger plug-in&lt;br /&gt;
   xdebug.remote_enable = on&lt;br /&gt;
   xdebug.remote_host = localhost&lt;br /&gt;
   xdebug.remote_port = 9000&lt;br /&gt;
   xdebug.remote_handler = dbgp&lt;br /&gt;
   ; StudioSG - vim debugger configuration end&lt;br /&gt;
* restart the web server.&lt;br /&gt;
&lt;br /&gt;
It will be possible to debug PHP scripts immediately after daemon restart.&lt;br /&gt;
&lt;br /&gt;
=== Using Vim / Vdebug ===&lt;br /&gt;
The last part of this article about '''Xdebug''' will be devoted to describing the few easy steps required to start and execute a debugging session of a PHP script file. Some images were included to better explain the main steps. The images refer to the interface of '''gVim''', the Vim GUI. GVim was used in place of plain Vim in order to take advantage of its wider window. &lt;br /&gt;
* Open with Vim the file targeted for debug.&lt;br /&gt;
: It is possible to pass the file name as a parameter in the command line:&lt;br /&gt;
      '''vim''' &amp;lt;path&amp;gt;/&amp;lt;file&amp;gt;&lt;br /&gt;
: Or to start Vim then use the ''':e''' &amp;lt;path&amp;gt;/&amp;lt;file_name&amp;gt; command to load the file from within the editor interface.&lt;br /&gt;
* Set a break point, that is a line of code where the execution will come to a halt and the debugging session will start.&lt;br /&gt;
: Vdebug provides a new command to Vim: ''':Breakpoint'''&lt;br /&gt;
&lt;br /&gt;
[[File:gvim_xdebug_breakpoint_set.jpeg|||Vdebug - Set a breakpoint]]&lt;br /&gt;
&lt;br /&gt;
* Start a web browser and load the URL of the desired page.&lt;br /&gt;
* Add variable '''XDEBUG_SESSION_START=1''' to the URL.&lt;br /&gt;
: A simple example: http://example.com/index.php?XDEBUG_SESSION_START=1&lt;br /&gt;
: A more complex example with an URL made of more than one variable: http://example.com/index.php?pg=11&amp;amp;amp;XDEBUG_SESSION_START=1&lt;br /&gt;
* Return to the Vim window and press '''F5'''.&lt;br /&gt;
&lt;br /&gt;
[[File:gvim_xdebug_session_activate.jpeg|||Vdebug - Start the debug session]]&lt;br /&gt;
&lt;br /&gt;
* Reload the URL within 20 seconds and '''the debug session will automatically start'''.&lt;br /&gt;
&lt;br /&gt;
[[File:gvim_xdebug_session_active.jpeg|||Vdebug - Active debug session]]&lt;br /&gt;
&lt;br /&gt;
* Return to the Vim window and press '''F4''' to execute code till the first available break point is encountered.&lt;br /&gt;
&lt;br /&gt;
[[File:gvim_xdebug_debug_in_progress.jpeg|||Vdebug - Debug in progress]]&lt;br /&gt;
&lt;br /&gt;
: The Vim window will be split in two columns. The left column shows the script source code and manages navigation commands. The right column is divided in boxes showing the local variables values, a list of open files in the order they were opened by the script and some more useful information that will help you decipher code behavior.&lt;br /&gt;
* Press '''F2''' to execute code and go to the next line. Note that when the line of code includes a function the function is evaluated, but its code will not be shown. Use the '''F3''' key to follow program flow in and out of functions.&lt;br /&gt;
* To dump the value of a variable move the cursor on it then press key '''F12'''&lt;br /&gt;
&lt;br /&gt;
[[File:gvim_xdebug_variable_dump.jpeg|||Vdebug - Visualizzare il contenuto di una variabile]]&lt;br /&gt;
&lt;br /&gt;
* Once concluded you can exit debug mode pressing the '''F6''' key.&lt;br /&gt;
&lt;br /&gt;
=== Appendix - Vdebug Commands ===&lt;br /&gt;
The table below contains '''some common Vdebug commands'''. The list is incomplete, but the included commands are enough to perform a full debug session. Please read the official documentation for a full description of Vdebug features and commands.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ '''Vdebug - Commands'''&lt;br /&gt;
|- bgcolor=&amp;quot;lightgrey&amp;quot;&lt;br /&gt;
! style=&amp;quot;width:240px&amp;quot; | Command || Description&lt;br /&gt;
|-&lt;br /&gt;
| '''F2''' || Step forward&lt;br /&gt;
|-&lt;br /&gt;
| '''F3''' || Step in (Shows function source code)&lt;br /&gt;
|-&lt;br /&gt;
| '''F4''' || Step out &lt;br /&gt;
|-&lt;br /&gt;
| '''F5''' || Start debugging&lt;br /&gt;
|-&lt;br /&gt;
| '''F6''' || Stop debugging&lt;br /&gt;
|-&lt;br /&gt;
| '''F7''' || Detach script from debugger&lt;br /&gt;
|-&lt;br /&gt;
| '''F9''' || Go to cursor&lt;br /&gt;
|-&lt;br /&gt;
| '''F10''' || Toggle break point&lt;br /&gt;
|-&lt;br /&gt;
| '''F11''' || Dump environment variables&lt;br /&gt;
|-&lt;br /&gt;
| '''F12''' || Dump variable under cursor&lt;br /&gt;
|-&lt;br /&gt;
| ''':Breakpoint''' &amp;lt;type&amp;gt; &amp;lt;args&amp;gt; || Add a break point &amp;lt;br&amp;gt; ''':help VdebugBreakpoints''' for more information&lt;br /&gt;
|-&lt;br /&gt;
| ''':VdebugEval''' &amp;lt;code&amp;gt; || Execute code and return results&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Leader&amp;gt;'''e''' || Execute highlighted expression and return results&lt;br /&gt;
|-&lt;br /&gt;
| ''':VdebugOpt''' debug_file &amp;lt;file&amp;gt; || Set a log file&lt;br /&gt;
|-&lt;br /&gt;
| ''':VdebugOpt''' debug_file_level 2 || Set log verbosity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
The procedure to install Xdebug on a Slackware Linux host was described in this paper. Then step by step installation instructions for Vdebug, a Vim extension enabling the text editor to interface with Xdebug, were provided and finally an example of a debug session was executed to show how Vim and Xdebug work together. The 5.6 release of PHP introduced a long awaited native debugger; its features and differences with Xdebug will be the subject of a later article.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For any feedback, questions, errors and such, please e-mail me at ''studiosg [at] giustetti [dot] net''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
External links&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* [http://www.php.net The PHP language home page]&lt;br /&gt;
* [http://php.net/manual/en/ The PHP manual]&lt;br /&gt;
* [http://pear.php.net The PEAR library home page]&lt;br /&gt;
* [http://pecl.php.net The PHP extensions project home page]&lt;br /&gt;
* [https://xdebug.org The Xdebug 2 home page]&lt;br /&gt;
* [http://phpdbg.com/docs PHPDbg: The next generation PHP debugger]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
{{footer_en | link_page=xdebug}}&lt;/div&gt;</summary>
		<author><name>Wikiuser</name></author>
	</entry>
</feed>