PHPackages                             gajus/bugger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. gajus/bugger

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

gajus/bugger
============

Bugger is a collection of functions for debugging PHP code.

0.2.1(12y ago)75337[10 issues](https://github.com/gajus/bugger/issues)BSD-3-ClauseCSSPHP &gt;=5.4

Since Apr 14Pushed 11y ago6 watchersCompare

[ Source](https://github.com/gajus/bugger)[ Packagist](https://packagist.org/packages/gajus/bugger)[ Docs](https://github.com/gajus/bugger)[ RSS](/packages/gajus-bugger/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Bugger
======

[](#bugger)

[![Build Status](https://camo.githubusercontent.com/3c3bb7046f5cf0fc26833d99aca3f2c12790e0e786c1978e818e0583e2957166/68747470733a2f2f7472617669732d63692e6f72672f67616a75732f6275676765722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/gajus/bugger)[![Coverage Status](https://camo.githubusercontent.com/809e8b1d0831ad2662d477ea3e0cfc33d698be8a770771b9ecbce850fb46c919/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f67616a75732f6275676765722f62616467652e706e673f6272616e63683d6d61737465722663616368653d313233)](https://coveralls.io/r/gajus/bugger?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/70407af8d0c8b7051661b7be7b859b632d7017dae63b219081ed301c0c4d4f8e/68747470733a2f2f706f7365722e707567782e6f72672f67616a75732f6275676765722f76657273696f6e2e706e67)](https://packagist.org/packages/gajus/bugger)[![License](https://camo.githubusercontent.com/bdd003c3ce63ab2ffb478d71b25a49996f44d248f08a70f6b2ebd02020a73253/68747470733a2f2f706f7365722e707567782e6f72672f67616a75732f6275676765722f6c6963656e73652e706e67)](https://packagist.org/packages/gajus/bugger)

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

API
---

[](#api)

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

### Trace

[](#trace)

```
/**
 * 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](./docs/static/image/trace.png)](./docs/static/image/trace.png)

### Stack

[](#stack)

```
/**
 * 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';
stack('a');
echo 'bar';
stack('b');
echo 'baz';
stack('c');
echo 'qux';
```

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

[![Stack output](./docs/static/image/stack.png)](./docs/static/image/stack.png)

### Tick

[](#tick)

```
/**
 * 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.
        break;
    }
}

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](./docs/static/image/tick.png)](./docs/static/image/tick.png)

Installation
------------

[](#installation)

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](http://uk1.php.net/manual/en/ini.core.php#ini.auto-prepend-file) setting to load `./src/autoload.php`.

Roadmap
-------

[](#roadmap)

- Support CLI.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

2

Last Release

4403d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b46b18abe058b038c677a9fa4aa6c39de7597196fb72a11add1f11600412a0e5?d=identicon)[gajus](/maintainers/gajus)

---

Top Contributors

[![gajus](https://avatars.githubusercontent.com/u/973543?v=4)](https://github.com/gajus "gajus (71 commits)")[![sumpygump](https://avatars.githubusercontent.com/u/676007?v=4)](https://github.com/sumpygump "sumpygump (8 commits)")[![Potherca](https://avatars.githubusercontent.com/u/195757?v=4)](https://github.com/Potherca "Potherca (2 commits)")

---

Tags

debugdumpbugger

### Embed Badge

![Health badge](/badges/gajus-bugger/health.svg)

```
[![Health](https://phpackages.com/badges/gajus-bugger/health.svg)](https://phpackages.com/packages/gajus-bugger)
```

###  Alternatives

[symfony/var-dumper

Provides mechanisms for walking through any arbitrary PHP variable

7.4k855.5M8.0k](/packages/symfony-var-dumper)[kint-php/kint

Kint - Advanced PHP dumper

2.8k19.3M283](/packages/kint-php-kint)[xrdebug/php

PHP client library for xrDebug

23920.3k2](/packages/xrdebug-php)[leeoniya/dump-r

a cleaner, leaner mix of print\_r() and var\_dump()

12368.1k5](/packages/leeoniya-dump-r)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[phalcon/dd

This package will add the `dd` and `dump` helpers to your Phalcon application.

24294.1k27](/packages/phalcon-dd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
