Debugging in Vivvo
Debugging is a step in development that is just impossible to avoid. Sooner or later, one way or the other, we all find ourselves scratching a head and trying to figure out why in the world that perfectly good looking piece of code keeps on refusing to work as it was supposed. To make this unpleasant task a little bit less tedious, Vivvo offers a couple of handy built-in tools, that can help you obtain a lot of useful information on various aspects of Vivvo. They are ready to be used right out-of-box, and are quite simple, but effective.
The simplest way to get some extra info is by passing debug=1 GET parameter to Vivvo. Make sure you are logged in as user with Administrator privileges, and then call your page like this:
http://www.example.com/index.php?debug=1
When called like that, Vivvo will insert an extra overlay on the top of your page, containing various useful information like all SQL queries, template, javascript and css files, in the order they've been called. If there are any errors they will be printed and marked in red color.

Don't forget, to see the above debug info, you must be logged in with Administrator privileges.
This is a very handy and simple to use tool for debugging various problems, especially helpful during template development, since you will be able to see in a second if there are any template errors, and where is the problem exactly. However, it's not ideal since debug output is being inserted directly into the page content, and in many cases that can create formatting or validation problems. This is particularly a big problem in case of AJAX calls, where any extra data can break the JSON format, and create JS errors. To solve these problems Vivvo has built-in support for debugging using FirePHP extension.
FirePHP is a plug-in for Firebug extension for Firefox browser, that can be used to print debug messages from your php code directly to Firebug’s console. Vivvo CMS has built-in support for using FirePHP library, and it's included with Vivvo so you can start using it right away. As you will see, it's very simple to use and comes extremely handy when you need to debug Ajax powered pages. All FirePHP’s messages are sent to browser by using special set of X-FirePHP-Data response headers, so it will not interfere with the rest of your page. This is specially important in case of Ajax calls, as it will not change your XML or JSON data, allowing for transparent debugging.

If you are logged in as an administrator user, and your FirePHP extension is enabled, Vivvo will automatically show warnings in your Firebug console in case of any error is encountered. This way you will be able to quickly notice and resolve any VTE error, missing template, CSS or JS file, SQL errors, or any other type of serious condition that needs your attention. We highly recommend to always have FirePHP enabled during the development phase, as sometimes you will not even notice a problem, until you spot warnings in your Firebug consoles.
Vivvo also has built-in option to show very detailed list of information on what is being processed by Vivvo, and in which order. To see this option in action try adding dump_info=1 GET parameter to Vivvo URL, like this:
http://www.example.com/index.php?dump_info=1
Just like previously mentioned debug=1 parameter, it will make Vivvo dump a lot of useful information, but this time all this data will go directly to Firebug console, and will not interfere with the content of the page or Ajax call. This option will give you a very deep and detailed overview of what Vivvo does when processing a request: list of all SQL queries executed, templates, CSS and JS files used, all of that in the chronological order. If any error or warning has been issued, it will be shown, too. Also you'll be able to see a table of all Vivvo configuration variables, as well as dump of url_manager variables that Vivvo has received (GET, POST and Cookie data).
To see the generated output, you must be logged in with Administrator privileges.

However, sometimes predefined output will not contain everything you need to debug the problem. In such situations you will probably want to open Vivvo code and insert a few lines of code yourself, to gather the exact information you need. While inserting plain old echo()'s will probably do the job in many cases, with Vivvo you have a much more elegant way to do it. As you can guess, FirePHP comes to our help again, and unlike echo()'s output, this will work with Ajax calls, too. To be able to call FirePHP’s functions directly, from Vivvo php code, you just need to include firePHP library. Than you can call firePHP function fb() to get the output you need:
// Make sure that firePHP library is included
require_once (VIVVO_FS_INSTALL_ROOT . 'lib/firePHP/fb.php');
// Now you are ready to call fb() function to output your messages to Firebug console directly
// Output a simple string message
fb('Hello World');
// Output a value of variable to Firebug console. It works for arrays and objects, too.
fb($foo);
// shows message in Firebug console marked as log entry
fb('Log message', FirePHP::LOG);
//shows message in Firebug console marked as info
fb('Info message', FirePHP::INFO);
//shows message in Firebug console marked as warning
fb('Warn message', FirePHP::WARN);
//shows message in Firebug console marked as error
fb('Error message', FirePHP::ERROR);
To learn more about FirePHP, and to install it in your browser please visit FirePHP's official site.

del.icio.us
Digg
Facebook