<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GinkgoMZD</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GinkgoMZD"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/GinkgoMZD"/>
	<updated>2026-06-30T05:56:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=How_to_debug_your_code&amp;diff=454556</id>
		<title>How to debug your code</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=How_to_debug_your_code&amp;diff=454556"/>
		<updated>2017-10-25T03:28:31Z</updated>

		<summary type="html">&lt;p&gt;GinkgoMZD: Reference newer documentation on logging and debugging features.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{page|needs improvement|Updated Joomla! System-debug plugin features not listed here.}}&lt;br /&gt;
&lt;br /&gt;
==Update==&lt;br /&gt;
Much of the below methods can still be valid for some quick and &#039;&#039;dirty&#039;&#039; debugging, however, there is sufficient functionality gains from the JLog class and the Debug System Plugin added since this page was created.&lt;br /&gt;
&lt;br /&gt;
From [[Using JLog]]:&lt;br /&gt;
 &#039;&#039;Joomla logging [JLog] gives you the ability to log messages to files and to the screen (within the Joomla! Debug Console at the bottom of the web page), and the main Joomla class which underpins this is JLog.  The logging can be controlled dynamically to some extent through the Joomla Global Configuration and by configuring the System – Debug plugin (which is shipped with Joomla).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The Easy Way 1 (echo)==&lt;br /&gt;
The simplest way to see what is going on inside your code is to temporarily add echo statements for variables to show their values on the screen. For example, say you want to know what the value of some variables are when $i is &amp;quot;5&amp;quot;. You could use code like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;PHP&amp;quot;&amp;gt;for ( $i = 0; $i &amp;lt; 10; $i++ ) {&lt;br /&gt;
	if ( $i == 5 ) {&lt;br /&gt;
		echo &#039;$i=&#039; . $i; &lt;br /&gt;
                // other echo statements &lt;br /&gt;
	}&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This works for simple situations. However, if you are planning on doing a lot of Joomla! development, it is worth the effort to install and learn an integrated development environment (IDE) that includes a real PHP debugger.&lt;br /&gt;
&lt;br /&gt;
==The Easy Way 2 (joomla message)==&lt;br /&gt;
Your code won&#039;t always display simple echo statements. In that case you can try this alternative, still easy way:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;PHP&amp;quot;&amp;gt;JFactory::getApplication()-&amp;gt;enqueueMessage(&#039;Some debug string(s)&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
You can choose different [[Display_error_messages_and_notices|message types]] which corresponds to grouping with different styles (colors mainly).&lt;br /&gt;
&lt;br /&gt;
==Using an IDE==&lt;br /&gt;
Check this 3 minutes video that shows [http://www.youtube.com/watch?v=sP4dHAuq2kc&amp;amp;feature=youtu.be how you can debug your code with a Browser and an IDE]&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|sP4dHAuq2kc}}&lt;br /&gt;
&lt;br /&gt;
Many Joomla! developers use the Eclipse IDE. This is free and includes a debugger. Instructions for installing it are available at [[Setting up your workstation for Joomla! development]].&lt;br /&gt;
&lt;br /&gt;
==Using the PHP Expert editor==&lt;br /&gt;
Another option is the PHP Expert editor with an installed extension for debugging. Add the following lines to the php.ini file:&lt;br /&gt;
&lt;br /&gt;
 extension=php_dbg.dll&lt;br /&gt;
 [Debugger]&lt;br /&gt;
 debugger.enabled=on&lt;br /&gt;
 debugger.profiler_enabled=off&lt;br /&gt;
&lt;br /&gt;
It is best to set profiler_enable to &amp;quot;off&amp;quot;. Then you need to set options in the Run/Options menu to use HTTP-server and the directory in which your script is located.&lt;br /&gt;
&lt;br /&gt;
If all options are correct, you may run your script in debug mode by clicking on the Debug button (F8)&lt;br /&gt;
==J!Dump==&lt;br /&gt;
An often handy extension that can be found in the JED is the J!Dump extension that will allow you to dump variable, stack traces, and system information into a popup window at run time. This extension works like the PHP command `var_dump` but formats the output in a much more readable fashion.&lt;br /&gt;
==JDEBUG==&lt;br /&gt;
To check whether the Website is in the debug mode, test the JDEBUG variable: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if(JDEBUG)&lt;br /&gt;
{&lt;br /&gt;
    //whatever debugging code you want to run&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debug mode can be enabled from the Joomla! Global Configuration under the System tab.  Once enabled the output of the debug plugin will be displayed at the bottom of each page.&lt;br /&gt;
&lt;br /&gt;
[[File:Jdebug-module.jpg|The JDebug Plugin output]]&lt;br /&gt;
&lt;br /&gt;
This plugin provides important information that can assist in debugging and improving the performance of your component.&lt;br /&gt;
&lt;br /&gt;
===Profile Information===&lt;br /&gt;
&lt;br /&gt;
The Profile Information tab from the debug plugin provides information about the time and memory taken to render the page based on each of the application events.  This can help to identify areas outside of network speed that are contributing to long page load times high server memory usage.&lt;br /&gt;
&lt;br /&gt;
[[File:Jdebug-profile.jpg|JDEBUG Profile]]&lt;br /&gt;
&lt;br /&gt;
===Database Queries===&lt;br /&gt;
&lt;br /&gt;
One of the most useful tabs is the Database Queries tab.  This will provide a log of all queries that have been executed while loading the page and identify both the time taken to execute the query and whether duplicate queries have occurred.  This is particularly useful when debugging performance problems on larger components as duplicate queries are often a contributing factor.&lt;br /&gt;
&lt;br /&gt;
[[File:Jdebug-query.jpg]]&lt;br /&gt;
&lt;br /&gt;
==JFirePHP==&lt;br /&gt;
Use the Joomla [http://extensions.joomla.org/extensions/miscellaneous/development/11343 JFirePHP extension].&lt;br /&gt;
&lt;br /&gt;
==Komodo IDE==&lt;br /&gt;
&lt;br /&gt;
[[Debugging Joomla with Komodo IDE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Video]]&lt;/div&gt;</summary>
		<author><name>GinkgoMZD</name></author>
	</entry>
</feed>