sfToolsPlugin
The sfToolsPlugin provides some tools and debugging functions.
sfDebugTools.class.php
Debugging functions:
dump() : Dumps an array or object. Displays, dies or returns the result.
Note that doctrine objects are automatically detected.
dump2() : Same function as dump() but more suitable and readable for a console debug.
getElapsedTime(): Get the elapsed time between 2 time references.
Installation
Usage
sfDebugTools.class.php
dump():
Print an object and stop the process
sfDebugTools::dump($this->getUser()->getAttributeHolder(), '$this->getUser()->getAttributeHolder()', true);
Will output:
Process stopped by sfDebugTools:dump()
» file : C:\wamp\www\symfony1.4.14\apps\frontend\modules\index\actions\actions.class.php
» line : 20
» class : indexActions
» function : executeIndex
$this->getUser()->getAttributeHolder() (sfNamespacedParameterHolder) :
sfNamespacedParameterHolder Object
(
[default_namespace:protected] => symfony/user/sfUser/attributes
[parameters:protected] => Array
(
)
)
Print an object without stopping the process
sfDebugTools::dump($this->getUser()->getAttributeHolder(), '$this->getUser()->getAttributeHolder()', false);
Retrieve the dump of an object
$dump = sfDebugTools::dump($this->getUser()->getAttributeHolder(), '$this->getUser()->getAttributeHolder()', false, true);
echo $dump;
dump2():
Acts the same way as dump() but doesn't display all the backtrace informations.
getElapsedTime():
Get the elapsed time between 2 time references:
$start = sfDebugTools::getMicroTimeNow();
usleep(rand(1, 1000000));
$end = sfDebugTools::getMicroTimeNow();
sfDebugTools::dump(sfDebugTools::getElapsedTime($start, $end), 'sleep in seconds', 0);
Will output:
sleep in seconds:
0.7101
Of course if's better to add a shortcut in your base actions class, so you can call
it with:
$this->dump(...);
TODO
Support
Send me an email or report bugs on the symfony TRAC, I could also answer if you ask on the
symfony mailing list.
Changelog
(check the changelog tab)
See you. COil :)
This plugin is sponsored by SQL-Technologies
