sfToolsPlugin - 1.0.1

The **sfToolsPlugin** provides some tools and debugging functions.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

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

    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

sfFileTools.class.php

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 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

SQL Technologies