Setting up XDebug with Joomla

Introduction

Joomla! CMS is platform for website development which is using by quite a large number of people today. I have started using this few years back and contributed in many ways. Every time a development is going on, we came across situations where we need to look in to variables’s instance values. In some situations I just print that variable value. However in complex situation a help of a debugger is essential. There are several methods to debug Joomla during development process and most of them are mentioned in this reference article [1]. In this article I am describing one of those method in detail.

Pre-requisites

In my case I had the following setup;

  • Joomla CMS installed
  • Phpstrom on Windows
  • XAMPP which runs Apache and SQL

Now it’s time to start setting up.

Configuring XDebug on XAMPP

  • Download xdebug library suites for php version and OS (https://xdebug.org/download.php)
  • Put the library in php/ext folder
  • Add Xdebug configuration to the end of php.ini file
  • Add desired host and port
  • Restart XAMPP server and check phpinfo to verify xdebug section

Sample Xdebug configuration for php.ini file [2]. “zend_extension_ts” is the path to locate downloaded library.

[XDebug]
zend_extension = “c:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll”
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = “c:\xampp\tmp”
;xdebug.profiler_output_name = “cachegrind.out.%t-%s”
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”
xdebug.remote_log=”c:\xampp\tmp\xdebug.txt”
xdebug.remote_port = 9000
xdebug.trace_output_dir = “c:\xampp\tmp”
; 3600 (1 hour), 36000 = 10h
xdebug.remote_cookie_expire_time = 36000

Configuring Web Browser

  • Install xdebug-helper extension in chrome browser [3] (there are other extensions for other browsers such as Firefox)
  • Go to extension options and change IDE key to PHPSTROM
  • Once you are logged to Joomla, switch to the Debug mode of plugin

Configuring Joomla to debug

Go to Global Configuration -> System and enable Debug System

Configuring PhpStrom

There are several ways of configuring remote debug from IDE side. Here I discuss on setting up as a remote debugger.

  • Go to debug configuration
  • Click + sign and click remote debugger
  • Click servers and add server’s debug configuration (xdebug host and port)
  • Add the correct IDE key and start debugger
  • Put some breakpoints and perform some actions Joomla!

Conclusion

There are several other ways of debugging Joomla as mention in [1]. Depending on the operating system, IDE and other facts, you may need to use different options.  I believe this article may help you to quickly setup debugging for Joomla! developments.

Reference

[1] How to debug your code – https://docs.joomla.org/How_to_debug_your_code

[2] Edit php.ini for XDebug – https://docs.joomla.org/Edit_PHP.INI_File_for_XDebug

[3] xdebug-helper – https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s