7

1) local or remote? I understand that the best practice for debugging is to have a local version of your website, but sometimes to make a local version of your current website can be very time consuming, especially when the site has been published and you just want do a few tweaks or fix some minor issues.

2) for the reason I mentioned above, I usually debug directly online. Here's a typical scenario I often encounter: The front end is reporting an error regarding a php file, I open the file and look at the line in question, it's in a method of a class. Then I var_dump related variables to see what's wrong, more than often it doesn't help, then I dive further into the function only to find out that the variables in question are related to one of the function's parameter. To know what exactly the parameter is, I need to find out where this function is invoked. Here is where I usually got stuck, I have to download the extension or even the whole website to local and do a in-text search for the function in all php files. Often there are scores of invocation, I have to try them one by one to see which one is causing problem. More than often this will lead to another function which I need to repeat the above process again.... This procedure is very time consuming and I often got frustrated and confused. Is this what everyone goes through?

So I am wondering how a sophisticated joomla developer would debug his site, what's the common practice for this? I was reading joomla documentations for debugging and and still working on configure a eclipse/xdebug environment, but I think the above questions still remain.

1
  • I think xdebug or similar PHP debugger is essential if you are going to code/debug on a regular basis.
    – TryHarder
    Feb 2, 2017 at 0:08

2 Answers 2

5

I am far from being a sophisticated developer and I also do debugging in online sites.

I use this marbelous tool

http://extensions.joomla.org/extension/j-dump

It have a lot of advantages over a single var_dump. Hope it works for you too.

3
  • Thank you! Do you also go throught the procedure I mentioned? (looking for function invocations, one leading to another, eventually encountering some joomla core classes liek JLegacy or JObject, then searching them in joomla documentation page.... only to find out one of the pages is marked "incomplete"....)
    – shenkwen
    Sep 28, 2015 at 16:08
  • By the way the description of the extension looks very promising, thank you again!
    – shenkwen
    Sep 28, 2015 at 16:09
  • jdump, use as dump($object) would show you the values of the $object variable, but you can also use dumpTrace(); that give you the calls done. Sep 28, 2015 at 16:29
5

Well, my personal preference is...it depends on what exactly need to be debugged.

If it's a simply element that's not displaying correctly due to some odd CSS, I'll simply get the live site running, open Firebug and sort it out.

If it's a PHP or JS related issue, I normally tend to take a copy of the site and run it on my local host. This is always the best approach as you may want to start var dumping variables testing code. People should not be seeing this happening on a live site.

Also, a lot of the time when debugging, you may find it good to use exit; to confirm code in conditional statements is working or not. Using this will (as you probably already know), result in a blank, site page. Another reason not to debug on a live site.

If you run into a point where it'll take too long to set the site up on your local host, I'd suggesting putting the site on offline mode temporarily until fixed.

A tip for the future when developing a site is to build it on your localhost and change Joomla's reporting in the Global Configuration to development so that all errors are shown and can be fixed before pushing live

1
  • Setting up a local debugger is very easy nowadays with xdebug and most development editors. You increase your development speed dramatically and also can do code walkthroughs by yourself
    – jdog
    Sep 28, 2015 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.