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. ## sfFileTools.class.php File tools functions: * `sanitizeFilename()`: Make a filename safe to use in the OS, command line... (need `iconv` to be installed) Installation ------------ * Install the plugin: $ symfony plugin:install sfToolsPlugin (Download it and unzip in your `/plugins` directory or use an SVN external `http://svn.symfony-project.com/plugins/sfToolsPlugin/tags/RELEASE_1_0_1/`) * Clear you cache $ symfony cc Usage ===== ## sfDebugTools.class.php ### `dump()`: * Print an object and stop the process [php] 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 [php] sfDebugTools::dump($this->getUser()->getAttributeHolder(), '$this->getUser()->getAttributeHolder()', false); * Retrieve the dump of an object as a string [php] $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: [php] $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 ## sfFileTools.class.php ### `sanitizeFilename()`: * Make a filename safe to use in the OS, command line: [php] echo sfFileTools::sanitizeFilename('--logö _ __ ___ ora@@ñ--~gé--.gif'); Will output: "logo_orange.gif" >**TIP** >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](http://www.strangebuzz.com) :) ---- This plugin is sponsored by [SQL-Technologies](http://www.sqltechnologies.com) ![SQL Technologies](http://www.php-debug.com/images/sql.gif)