![]() |
|
sfToolsPlugin - 1.0.1The **sfToolsPlugin** provides some tools and debugging functions. |
|
![]() |
4
users
Sign-in
to change your status |
The sfToolsPlugin provides some tools and debugging functions. * sfDebugTools (dump(), dump2(), getElapsedTime()) * sfFileTools (sanitizeFilename()) |
Useful debug or tools classes for symfony. As the name of this plugin is quiet generic, don't hesitate to send me your contribution request if you want to add a "tool", "function", whatever could fit in this plugin.
| Name | Status | |
|---|---|---|
|
|
lead | rf.oohay <<ta>> lioc_frq |
Plugin by Vernet Loïc aka COil. (qrf_coil[at]yahoo[dot]fr)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT license | 1.0.1stable | 03/11/2011 |
| 1.0.0stable | MIT license | 1.0.0stable | 21/10/2011 |
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT license | 1.0.1stable | 03/11/2011 |
| 1.0.0stable | MIT license | 1.0.0stable | 21/10/2011 |
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT license | 1.0.1stable | 03/11/2011 |
| 1.0.0stable | MIT license | 1.0.0stable | 21/10/2011 |
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT license | 1.0.1stable | 03/11/2011 |
| 1.0.0stable | MIT license | 1.0.0stable | 21/10/2011 |
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT license | 1.0.1stable | 03/11/2011 |
The sfToolsPlugin provides some tools and debugging functions:
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.File tools functions:
sanitizeFilename(): Make a filename safe to use in the OS, command line...
(need iconv to be installed)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
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 as a string
$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
sanitizeFilename():Make a filename safe to use in the OS, command line:
echo sfFileTools::sanitizeFilename('--logö _ __ ___ ora@@ñ--~gé--.gif');
Will output:
"logo_orange.gif"
Of course if's better to add a shortcut in your base
actionsclass, so you can call it with:$this->dump(...);
Send me an email or report bugs on the symfony TRAC, I could also answer if you ask on the symfony mailing list.
(check the changelog tab)
See you. COil :)
This plugin is sponsored by SQL-Technologies

