2017 © Pedro Peláez
 

library stop

nice output for debug functions for PHP 5.3

image

ivoba/stop

nice output for debug functions for PHP 5.3

  • Monday, May 26, 2014
  • by ivoba
  • Repository
  • 1 Watchers
  • 8 Stars
  • 18,962 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Stop

Stop is a lightweight Dumper for PHP 5.3+ , thus a replacement for echo '<pre>';print_r($var);exit;, (*1)

Build Status Total Downloads Dependency Status, (*2)

During developing pretty often i found myself typing: echo '<pre>';print_r($var);exit; or var_dump($var);exit;, (*3)

So this lib provides:, (*4)

  • shortcut functions
  • some more infos as File, Line & Memory
  • some nicer rendering with Twitter Bootstrap,
  • options for return or continue & hide which will print to javascript console
  • disable Stop for prod env
  • autoloading
  • extensibility, if youd like to use jqueryUI f.e just subclass the Dumper and set the class
  • context awareness: if you are in console it will render in text mode, if in ajax mode it will render in json mode
  • dumper for json strings
  • stop_type as a better version of var_dump(get_class($var));exit;

Its pretty lightweight since it basically just uses PHP functions plus some sugar. If you need more power have a look at: https://github.com/raulfraile/ladybug or http://raveren.github.io/kint/, (*5)

Install

via composer, put this in your require block:, (*6)

"ivoba/stop": "dev-master"

then, (*7)

composer update ivoba/stop

Using Stop

Functions:

By default, resp. via composer install, Stop will include global functions to ease access to the debug methods, (*8)

this is probably the fastest way with or without IDE Autocompletion.
If you also have functions named stop or stop_dump in your project: rename them, dude! No mercy! or use the class ;), (*9)

this will output print_r($var) in a code block and will exit the script:, (*10)

stop($var); or the shortcut _S($var);, (*11)

this will output var_dump($var) in a code block and will exit the script:, (*12)

stop_dump($var); or the shortcut _SD($var);, (*13)

Options

There are 3 options that can be passed as parameters:, (*14)

  • $continue: if this is true the script will not exit, default is false
  • $hide: if this is true it will print to javascript console, default is false
  • $return: if this is true the script will return the output, default is false

Shortcut functions for options:, (*15)

  • _SG($var); Stop and Go! (resp. print_r)
  • _SGH($var); Stop and Go and Hide! (resp. print_r)
  • _SDG($var); Stop Dump and Go! (resp. var_dump)
  • _SDGH($var); Stop Dump and Go and Hide! (resp. var_dump)
  • _SJ($json); Stop Dump as Json! (decodes a json string and send it inside the dump object as json to the browser. Use browser addons like JSONovich for pretty rendering.)
  • _ST($var); StopType! (resp. get_type | get_class & class_uses & class_implements & class_parents)
  • _STG($var); StopType and Go! (resp. get_type | get_class & class_uses & class_implements & class_parents)

Static Class Methods:

   use \Stop\Stop;
   Stop::it($var, \Stop\Dumper::PRINT_R, $continue, $hide, $return);
   Stop::dump($var, $continue, $hide, $return);
   Stop::print_r($var, $continue, $hide, $return);

OO Style:

    $Stop = new \Stop\Dumper($hide, $continue, $return);  
    $Stop->printr($var);
    $Stop->dump($var);

Requirements

PHP > 5.3 nothing more
I recommend however to install XDebug for nicer var_dump rendering., (*16)

The Versions

26/05 2014

dev-master

9999999-dev http://github.com/ivoba/stop

nice output for debug functions for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print_r var_dump dumper

26/05 2014

0.2.1

0.2.1.0 http://github.com/ivoba/stop

nice output for debug functions for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print_r var_dump dumper

26/05 2014

dev-get_type

dev-get_type http://github.com/ivoba/stop

nice output for debug functions for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print_r var_dump dumper

26/05 2014

0.2.0

0.2.0.0 http://github.com/ivoba/stop

nice output for debug functions for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print_r var_dump dumper

12/03 2014

0.1.0

0.1.0.0 http://github.com/ivoba/stop

nice output for debug functions for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

debug dump print_r var_dump dumper