Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
There are several ways you can debug your php code depending on the issues you are having. Most of the methods below will display a string, so you also need to know how to convert arrays and objects to strings in order to display them.
- Converting other types of data to strings
- Converting an array to a string
- Converting an object to a string
- PHP echo
- Joomla's standard message area
- Fabrik's debugging infrastructure
- Turning on Fabrik's debugging system
- Permanent debugging statements
- Browser Developer's Tools
- Use your browser's Developer's Tools
- Joomla JDump extension
- See also...
Converting other types of data to strings(top)
Converting an array to a string(top)PHP:$string = json_encode($array);
Converting an object to a string(top)Assumiong that your object implements a __toString() function:
PHP:$string = (string) $object;
PHP echo(top)The most obvious way to output debugging information is to use the php "echo" statement. However, this is not always as straightforward as you might think because the output will often appear somewhere in your HTML which may not be immediately obvious or even visible, but can sometimes be missing altogether if you outputted it during a php output buffer capture ("ob_start"):
PHP:echo "$string = " . $string;
You also need to be aware that if page headers are still being created, your output will terminate these and may create other output oddities.
Joomla's standard message area(top)Possibly the easiest way to put a debug message on screen is to send it to Joomla's standard message area:
Fabrik's debugging infrastructure(top)If you want to leave debugging code permanently in your php, then you can use Fabrik's own debugging system.
Turning on Fabrik's debugging system(top)To view additional debug output showing what Fabrik is doing, you need to do two things:
- Set 'allow fabrik debug' to either 'Yes' or 'Debug JS' in Fabrik's global parameters.
- Add to the end of the URL the following string:
Permanent debugging statements(top)To display your own debugging information alongside Fabrik's, use:
Browser Developer's Tools(top)To get debugging information when the output is being sent in response to an Ajax call for e.g. field or form validation or for calc elements, and is not immediately visible the browser window.
You can use the following methods :
Use your browser's Developer's Tools(top)To display variables, you can use the PHP var_dump() function :
SyntaxError: JSON.parse: unexpected character
If you want to display many variables, you can write :
PHP:echo "found : " . $found . "\n";
echo "status : " . $status; exit;
And don't forget to write "exit;" on the last line !
Joomla JDump extension(top)JDump allows you to display your debugging output in a popup window, without stopping the execution of your code. Just insert in your code something like:
PHP:dump($variable, 'Variable Name');