How do i debug my callback scripts?
I have a deal_management function which does grocery CRUD
and i have a
callback_after_insert( array( $this, ‘insert_coupon_codes’ ) );
since the insertion in the database is not working in my function insert_coupon_codes I have no way to know or view my SQL.
Is there any function by which i can debug my php scripts inside the callback function without any hacks?
I did print_r() and var_dump() but these do not seem to work inside the callback function.
First of all ensure that call_user_func works properly with your function. So for example you can try this:
The problem in callbacks is that there is no error displaying when something goes wrong. So for example if you have
test2 function does not exist. But there is no error anywhere.
If everything goes fine with this, you can simply debug your insert/update with a simply hack.
In grocery CRUD the insert/update/delete is an ajax call, so to debug your project, you have to debug it with the firefox firebug.
You can have your var_dump or print_r and see the ajax call response from your firebug. If you are not familiar with how to use firebug,
I have a little hacking solution for the debug.
Simply go to your add or edit form and disable all the javascripts
(You can download Web Developer for firefox and then click Disable>Disable Javascript>All Javascript).
Then if you refresh the form add or edit and push submit, there will be the ajax request in a view.
So there you can see your var_dump or print_r.
Still grocery CRUD doesn’t support debugging for callbacks so I think its a good solution for now. Beside this for debugging without hacking you can always easily have the log_message function of codeigniter. For more you can see at http://ellislab.com/codeigniter/user-guide/general/errors.html