Friday, August 30, 2013

Live site - Forget the fear & work with full freedom


We work on live site which must be using by many users of the site over the world wide. Many times problem occurs only on a live site so in such cases you can't do anything on your working instance & you want to debug only on live site to fix the issue. There are many CMS like Joomla, Drupal which easily allows debug or error reporting mode. However this is not just enough in many situation. There is possibility of site getting crashed if you have done any hacks or some patch work & this fails when you only want to see the errors or print any query & die statement.
Yesterday i was suffering from same problem. There was a Joomla site which was live & there were many users online & have to look the code by trial & error basis like print some queries & execute die statement. Simple & sweet idea came in my mind & i just added a parameter like testuser=atpatil in url & based on this parameter debug the code by executing die statement. This won't affect to anyone besides me. In php you can add following code.
if($_GET['testuser'] == "atpatil")
{
echo 'Write or echo anything you want to solve your issue here';
die;
}
When i show the exact problem on live site to my boss. He said, "How can you print query & such coding stuff on live site." When I told about this simple trick he just laughed. Just try this simple trick to debug the code & let me know whether it helps. You can use console.log as well but this blog post is all about die statement.

2 comments:

  1. Nice one Amol ! :) Console.log works best. How about a small utility plugin that makes doing this easier that we can give as a free release on Techjoomla ?

    ReplyDelete
  2. Sure, We can do it.

    ReplyDelete