Toolkit helper class

The Jaws_Toolkit class is home to many classes which have nothing in common but being helpful. Here is a list of functionalities assured by this class.

Assertion and exception handling

When the Jaws core object is initiated, it automatically registers Jaws_Toolkit::exceptionHandler() and Jaws_Toolkit::assertionHandler() as the exception and assertion handlers for the running script. The default handlers make sure that the assertions and exceptions are properly logged or, if it is impossible to log, that the message is printed to the user. To register Jaws_Toolkit's exception and assertion handlers, the Jaws_Toolkit::registerExceptionHandler() and Jaws_Toolkit::registerAssertionHandler() methods are used.


If the Jaws 2 API is not bundled, all the class files need to be loaded separately. By default, when initiated, the Jaws core object registers Jaws_Toolkit's autoloader. If your script does not run from the base directory and you wish to use autoloading, you need to specify a prefix when you register the autoloader with the Jaws_Toolkit::registerAutoload(string $prefix) method.

XML walkthrough

If you need to parsed a XML file into an array, you can accomplish that with the Jaws_Toolkit::xmlWalkThrough(SimpleXMLElement &$obj) method. Simply pass the SimpleXML element and the method will return an array.

Path to class file

If you need to get the path to a class file, you can use the Jaws_Toolkit::classToPath(string $class) function. It will simply return the path in a string, without the .php extension. This method also works for vendor libraries if they are registered in the function. See the source for more details.

Customized backtrace print

PHP's debug_backtrace() produces way too much data when used with complex objects, like Doctrine records. This is why a customized backtrace parser was developed. Instead of printing the content of an object used as a parameter, it simply prints its class name. It is accessed with method Jaws::backtraceToString(array $backtrace) and returns a string containing the backtrace.

< Click here to go back to Jaws 2 internals section