This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Bugger is a collection of functions for debugging PHP code.

Installs: 29

Dependents: 0

Suggesters: 0

Security: 0

Stars: 79

Watchers: 6

Forks: 7

Open Issues: 10


0.2.1 2014-04-25 11:30 UTC

This package is not auto-updated.

Last update: 2021-11-27 00:40:53 UTC


Build Status Coverage Status Latest Stable Version License

Bugger is a collection of functions for debugging PHP code. Use it to:

  • Dump information about a variable
  • Set breakpoints in loops

Bugger is designed to be used when remote debugger is not available. It allows to dump information about a variable together with the debug backtrace (trace method), it allows to collect information about multiple variables during the script execution and dump them at the end of the script execution (stack method), as well as trap iterations (tick method).


Bugger API is exposed to the global namespace via three functions:


 * Terminates the script, discards the output buffer, dumps information about the expression including backtrace up to the `trace` call.
 * @param mixed $expression The variable you want to dump.
 * @return null
trace ( mixed $expression );

Trace is used to dump information about the expression including the backtrace information. Trace will attempt to discard existing output buffer. If output buffer cannot be discaded because it has been already sent to the browser, then Bugger will attempt to clear the previous output using client-side script.

Trace output


 * Stacks information about the expression and dumps the stack at the end of the script execution.
 * @param mixed $expression The variable you want to dump.
 * @return null
stack ( mixed $expression );

Stack is identical to trace except that calling stack will not terminate the script at the time of the call. If stack is called at least once during the script execution, then at the end of the script execution output buffer will be discarded and replaced with the collected stack dump, e.g.

echo 'foo';
echo 'bar';
echo 'baz';
echo 'qux';

In the above example, 'foo', 'bar', 'baz' and 'qux' will be discarded.

Stack output


 * Tracks the number of times tick function itself has been called and returns true
 * when the desired number within the namespace is reached.
 * @param int $true_after Number of the itteration after which response is true.
 * @param string $namespace Itteration namespace.
 * @return boolean
tick ( int $true_after [, string $namespace = 'default' ] )

tick is used to catch script execution in loop or recursive calls. tick returns true when it has been executed a predefined number of times or more, e.g.

while (true) {
    if (tick(10)) {
        // Tick will return true after 10 itterations.

tick(4, 'test'); // false
tick(4, 'test'); // false
tick(4, 'test'); // false
tick(4, 'test'); // true
tick(4, 'test'); // true
tick(4, 'test'); // true

tick can be used together with stack or trace to capture the state of a particular itteration or multiple itterations.

Tick output


The recommended way to use Bugger is through Composer.

    "require": {
       "gajus/bugger": "0.2.*"

If you want to use Bugger across the server, then use auto_prepend_file setting to load ./src/autoload.php.


  • Support CLI.