PHPackages                             buggregator/trap - 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. [CLI &amp; Console](/categories/cli)
4. /
5. buggregator/trap

ActiveLibrary[CLI &amp; Console](/categories/cli)

buggregator/trap
================

A simple and powerful tool for debugging PHP applications.

1.15.1(4mo ago)2591.7M↓34.1%16[32 issues](https://github.com/buggregator/trap/issues)[4 PRs](https://github.com/buggregator/trap/pulls)20BSD-3-ClausePHPPHP &gt;=8.1CI passing

Since May 17Pushed 4mo ago6 watchersCompare

[ Source](https://github.com/buggregator/trap)[ Packagist](https://packagist.org/packages/buggregator/trap)[ Docs](https://buggregator.dev/)[ Fund](https://boosty.to/roxblnfk)[ RSS](/packages/buggregator-trap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (72)Used By (20)

 [![logo](https://github.com/buggregator/trap/raw/master/resources/payloads/logo.png?raw=true)](https://github.com/buggregator/trap/blob/master/resources/payloads/logo.png?raw=true)

Revolutionize Your Debugging Experience with PHP

Buggregator Trap
================

[](#buggregator-trap)

[![Twitter](https://camo.githubusercontent.com/91c1c3b545d03e0c79f91364259b2814308d2b3786c67c8578740879528ff37c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d466f6c6c6f772d626c61636b3f7374796c653d666c61742d737175617265266c6f676f3d58)](https://twitter.com/buggregator)[![Discord](https://camo.githubusercontent.com/df685ba0ca11bc2f01bf86b9bb7e6b2f834fc5e2b012bf76e48be7fd64eb6137/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f7374796c653d666c61742d737175617265266c6162656c3d4a6f696e266d6573736167653d446973636f7264266c6f676f3d446973636f726426636f6c6f723d253233353836354632)](https://discord.gg/qF3HpXhMEP)[![Support](https://camo.githubusercontent.com/92a5c9c142a4b40702e8f5905faa1afae6cfc4f79c417502e83bce1e2c90cf5f/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f7374796c653d666c61742d737175617265266c6162656c3d537570706f7274266d6573736167653d254532253944254134266c6f676f3d47697448756226636f6c6f723d253233666530303836)](https://patreon.com/roxblnfk)

**Trap** is a package designed to enhance the debugging experience in conjunction with the Buggregator Server.
Trap includes:

- A set of functions for direct interaction with any Buggregator server.
- Extensions for Symfony VarDumper that become active immediately after installing Trap.
- A minimized version of the [Buggregator Server](https://github.com/buggregator/server) that does not require Docker and is intended solely for local use.
- Use PHPStorm? Consider using Trap with the [Buggregator Plugin](https://github.com/buggregator/phpstorm-plugin) for a seamless debugging experience.

**Table of content:**

- [Installation](#installation)
- [Overview](#overview)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

To install Buggregator Trap in your PHP application, add the package as a dev dependency to your project using Composer:

```
composer require --dev buggregator/trap -W
```

[![PHP](https://camo.githubusercontent.com/6afc25ba29e37febf52fe850127cb2cc7e717629a131e1d92e19ff43bdfd0510/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6275676772656761746f722f747261702e7376673f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://packagist.org/packages/buggregator/trap)[![Latest Version on Packagist](https://camo.githubusercontent.com/273c57dfd973e9a8621d87c4b61ccf73ed1c132cb027c982c22a1ff6dd89e643/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6275676772656761746f722f747261702e7376673f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://packagist.org/packages/buggregator/trap)[![License](https://camo.githubusercontent.com/fd0f35dd0111add78bfdc28f1b9fc752e492fcadf74676c544a492523548c7ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6275676772656761746f722f747261702e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/348f5719b4ab1cbc1deb15afb839555d5cf4b1a50778b3e91019cb2fdc3ee969/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6275676772656761746f722f747261702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/buggregator/trap)

And that's it. Trap is [ready to go](#usage).

### Binary

[](#binary)

If you prefer to use Trap as a binary, you can install it globally using [Dload](https://github.com/php-internal/dload):

```
dload get trap
```

### Phar

[](#phar)

Sometimes your project may conflict with Trap's dependencies, or you might be interested in using only the local server (e.g., for analyzing local profiler files). In this case, consider installing Trap as a Phar (a self-contained PHP executable). Using wget:

```
wget https://github.com/buggregator/trap/releases/latest/download/trap.phar
chmod +x trap.phar
./trap.phar --version
```

Using [Phive](https://phar.io/):

```
phive install buggregator/trap
```

Overview
--------

[](#overview)

Buggregator Trap provides a toolkit for use in your code. Firstly, just having Buggregator Trap in your package enhances the capabilities of Symfony Var-Dumper.

If you've already worked with `google/protobuf`, you probably know how unpleasant it can be. Now let's compare the dumps of protobuf-message: on the left (with trap) and on the right (without trap).

[![trap-proto-diff](https://private-user-images.githubusercontent.com/4152481/284049817-30662429-809e-422a-83c6-61d7d2788b18.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjQ3MTMsIm5iZiI6MTc3NTI2NDQxMywicGF0aCI6Ii80MTUyNDgxLzI4NDA0OTgxNy0zMDY2MjQyOS04MDllLTQyMmEtODNjNi02MWQ3ZDI3ODhiMTguZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWJkNTBkODA1OGEzNGMxM2I5MjY3YTE5ZDlhNGQ1ZTc5YThlODFkNjVmN2EyMjUyY2NjYzBhOWFiODc5M2ZiMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.RV5ua8O4k8oSYa-TTqwppkbK3wmnbs4mLQWyQSlV9W8)](https://private-user-images.githubusercontent.com/4152481/284049817-30662429-809e-422a-83c6-61d7d2788b18.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjQ3MTMsIm5iZiI6MTc3NTI2NDQxMywicGF0aCI6Ii80MTUyNDgxLzI4NDA0OTgxNy0zMDY2MjQyOS04MDllLTQyMmEtODNjNi02MWQ3ZDI3ODhiMTguZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWJkNTBkODA1OGEzNGMxM2I5MjY3YTE5ZDlhNGQ1ZTc5YThlODFkNjVmN2EyMjUyY2NjYzBhOWFiODc5M2ZiMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.RV5ua8O4k8oSYa-TTqwppkbK3wmnbs4mLQWyQSlV9W8)

This simultaneously compact and informative output format of protobuf message will be just as compact and informative in the Buggregator Server interface. Now, working with protobuf is enjoyable.

---

Buggreagtor Trap includes a console application - a mini-server. The application is entirely written in PHP and does not require Docker to be installed in the system. It may seem like it's just the same as the `symfony/var-dumper` server, but it's not. Buggregator Trap boasts a much wider range of handlers ("traps") for debug messages:

- Symfony var-dumper,
- Monolog,
- Sentry,
- SMTP,
- HTTP dumps,
- Ray,
- Any raw data

You can effortlessly visualize and analyze console information about various elements of your codebase.

Here's a sneak peek into the console output you can expect with Trap:

symfony/var-dumper (proto)Binary Data[![var-dumper](https://private-user-images.githubusercontent.com/4152481/258665932-f4c855f5-87c4-4534-b72d-5b19d1aae0b0.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjQ3MTMsIm5iZiI6MTc3NTI2NDQxMywicGF0aCI6Ii80MTUyNDgxLzI1ODY2NTkzMi1mNGM4NTVmNS04N2M0LTQ1MzQtYjcyZC01YjE5ZDFhYWUwYjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDgwZTcwZTVhN2JhMGNmNTViYzRlOTU5MGUxMzM4NjQ1ZTZjNDM0YmFiYjJhNmUwNzNlYWYwNjJjMzcwYzg4NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.eOiqLIqxrPOs9BRXKOkzRMMqAl4VeRocD9OE30EUWyI)](https://private-user-images.githubusercontent.com/4152481/258665932-f4c855f5-87c4-4534-b72d-5b19d1aae0b0.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJj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tQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWYyNjAyMTZhMzQ5MDg4OWM1Zjc3NTRmYTg3MmM4ZjkyYzFkNDRjYTBkNzU2MjcxMDA2MjU5NTc3YTJmMWVkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.wGWkckS9yfl6ms1eoiBoPGKXWrPqDGBOalqHF8k8KoI)](https://private-user-images.githubusercontent.com/4152481/258666493-cd8788ed-b10c-4b9a-b2e2-baa8912ea38d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjQ3MTMsIm5iZiI6MTc3NTI2NDQxMywicGF0aCI6Ii80MTUyNDgxLzI1ODY2NjQ5My1jZDg3ODhlZC1iMTBjLTRiOWEtYjJlMi1iYWE4OTEyZWEzOGQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWYyNjAyMTZhMzQ5MDg4OWM1Zjc3NTRmYTg3MmM4ZjkyYzFkNDRjYTBkNzU2MjcxMDA2MjU5NTc3YTJmMWVkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.wGWkckS9yfl6ms1eoiBoPGKXWrPqDGBOalqHF8k8KoI)SMTP Mail TrapHTTP Dump[![smtp](https://private-user-images.githubusercontent.com/4152481/258666045-b11c4a7f-072a-4e66-b11d-9bbd3177bf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Am6pBanlw261xcUqezk)](https://private-user-images.githubusercontent.com/4152481/258666323-48201ce6-7756-4402-8954-76a27489b632.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjQ3MTMsIm5iZiI6MTc3NTI2NDQxMywicGF0aCI6Ii80MTUyNDgxLzI1ODY2NjMyMy00ODIwMWNlNi03NzU2LTQ0MDItODk1NC03NmEyNzQ4OWI2MzIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWE5YjkyN2Y3Y2Q1ZGUyYzMxYWU0MmFiYmQ4YTgyNzY0Y2MwNTg4MDM5YzUwYjYzOWY3YmUzNDgwZDFkMGFmMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.QZdhMD4JiLaAk5gbjZnSGhmhAm6pBanlw261xcUqezk)---

Additionally, you can manually set traps in the code. Use the `trap()` function, which works almost the same as Symfony's `dump()`, but configures the dumper to send dumps to the local server, unless other user settings are provided.

Also, the `trap()` has a lot of useful options:

```
// Limit the depth of the dumped structure
trap($veryDeepArray)->depth(3);

foreach ($veryLargeArray as $item) {
    // We don't need to dump more than 3 items
    trap($item)->times(3);
}

// Dump once if the condition is true
trap($animal)->once()->if($var instanceof Animal\Cat);
```

---

Tip

Feature in development: add the flag `--ui` to rise the web interface of the Buggregator Server without docker. [![trap-ui](https://private-user-images.githubusercontent.com/4152481/291054832-1ccc2c85-2f81-4b62-8ae7-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pYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEwMDEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDVlODJmNzdmMmRkZjRhMjIyNzA3OWRiNDQ2ODcwMmVhYTQ5NzUxYWM3NjhjOTk0ZDU3MDk4ZDljMTBmNGJiZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.RpS_nFeiAy4B8qmci0NBhMvZede69maO4iAAcX6rSho)

---

We care about the quality of our products' codebase and strive to provide the best user experience. Buggregator Trap has passed the Proof of Concept stage and is now an important part of the Buggregator ecosystem. We have big plans for the development of the entire ecosystem and we would be delighted if you join us on this journey.

Usage
-----

[](#usage)

After successfully [installing](#installation) Buggregator Trap, you can initiate the debugging process by using the following command:

```
vendor/bin/trap
```

This command will start the Trap server, ready to receive any debug messages. Once a debug message is trapped, you will see a convenient report about it right here in the terminal.

Then just call the `trap()` function in your code:

```
// dump the current stack trace
trap()->stackTrace();

// dump a variable with a depth limit
trap($var)->depth(4);

 // dump a named variables sequence
trap($var, foo: $far, bar: $bar);

// dump a variable and return it
$responder->respond(trap($response)->return());
```

> **Note**: The `trap()` function configures `$_SERVER['REMOTE_ADDR']` and `$_SERVER['REMOTE_PORT']` automatically, if they are not set.

Also, there are a couple of shortcuts here:

- `tr(...)` - equivalent to `trap(...)->return()`
- `td(...)` - equivalent to `trap(...); die;`

If called without arguments, they will display a short stack trace, used memory, and time between shortcut calls.

```
function handle($input) {
    tr(); // Trace #0  -.---  3.42M

    $data = $this->prepareData($input);

    tr(); // Trace #1  0.015ms  6.58M

    $this->processor->process(tr(data: $data));

    td(); // exit with output: Trace #2  1.15ms  7.73M
}
```

### Default port

[](#default-port)

Trap automatically recognizes the type of traffic. Therefore, there is no need to open separate ports for different protocols. By default, it operates on the same ports as the Buggregator Server: `9912`, `9913`, `1025`, and `8000`. However, if you wish to utilize a different port, you can easily make this adjustment using the `-p` option:

```
vendor/bin/trap -p9912 --ui=8000
```

Environment variables can also be used to set endpoints:

- `TRAP_TCP_PORTS` - for TCP traffic: `9912,9913,1025,8000`
- `TRAP_TCP_HOST` - for the TCP host (default: `127.0.0.1`)
- `TRAP_UI_PORT` - for the web interface: `8080`

### Choosing Your Senders

[](#choosing-your-senders)

Buggregator Trap provides a variety of "senders" that dictate where the dumps will be sent. Currently, the available sender options include:

- `console`: Shows dumps directly in the console.
- `server`: Sends dumps to a remote Buggregator server.
- `file`: Saves dumps in a file for later use.
- `mail-to-file`: Creates a folder for each recipient and saves each message as a JSON file. Useful for testing mails. If you send a mail `To: foo@example.com, bar@example2.org`, the following folders will be created:
    - `runtime/mail/foo@example.com`
    - `runtime/mail/bar@example2.org`

By default, the Trap server is set to display dumps in the console. However, you can easily select your preferred senders using the `-s` option.

For instance, to simultaneously use the console and file senders, you would input:

```
vendor/bin/trap -sconsole -sfile
```

Contributing
------------

[](#contributing)

We believe in the power of community-driven development. Here's how you can contribute:

- Share your experience:
    - If you find a bug or have a feature request, please [create an issue](https://github.com/buggregator/trap/issues).
    - Help others by answering questions on [Discord](https://discord.gg/qF3HpXhMEP) or asking your own.
    - Share the love and tell others about Buggregator.
- Write code:
    - If you want to fix a bug or add a feature, let us know in the issue tracker. [There are issues](https://github.com/buggregator/trap/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) labeled "help wanted" that are a good place to start.
    - Have good documentation writing skills? We'd love your help improving our [docs](https://github.com/buggregator/docs/tree/master/docs).
- Sponsor us:
    - If you use Buggregator in a commercial setting, consider [becoming a sponsor](https://patreon.com/roxblnfk) to help us maintain and improve the project.
    - You also can promote a specific feature or bug fix. We mark sponsored tasks with the honorary label [`SPONSORED`](https://github.com/buggregator/trap/issues?q=label%3ASPONSORED).

License
-------

[](#license)

Buggregator Trap is open-sourced software licensed under the BSD-3 license.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance72

Regular maintenance activity

Popularity60

Solid adoption and visibility

Community37

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 75.5% 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 ~14 days

Recently: every ~28 days

Total

67

Last Release

142d ago

Major Versions

0.4.0 → 1.0.02023-08-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/773481?v=4)[Pavel Buchnev](/maintainers/butschster)[@butschster](https://github.com/butschster)

![](https://www.gravatar.com/avatar/110fa17dca123e71e4ef4132d1d6a66d20058a07fc6118e716dd67dd4316e886?d=identicon)[roxblnfk](/maintainers/roxblnfk)

---

Top Contributors

[![roxblnfk](https://avatars.githubusercontent.com/u/4152481?v=4)](https://github.com/roxblnfk "roxblnfk (475 commits)")[![lotyp](https://avatars.githubusercontent.com/u/94047334?v=4)](https://github.com/lotyp "lotyp (70 commits)")[![butschster](https://avatars.githubusercontent.com/u/773481?v=4)](https://github.com/butschster "butschster (46 commits)")[![gam6itko](https://avatars.githubusercontent.com/u/3841197?v=4)](https://github.com/gam6itko "gam6itko (11 commits)")[![k2gl](https://avatars.githubusercontent.com/u/2846079?v=4)](https://github.com/k2gl "k2gl (10 commits)")[![DimaTiunov](https://avatars.githubusercontent.com/u/5381110?v=4)](https://github.com/DimaTiunov "DimaTiunov (5 commits)")[![dimajolkin](https://avatars.githubusercontent.com/u/7441874?v=4)](https://github.com/dimajolkin "dimajolkin (4 commits)")[![lee-to](https://avatars.githubusercontent.com/u/1861327?v=4)](https://github.com/lee-to "lee-to (3 commits)")[![chachanagov](https://avatars.githubusercontent.com/u/27193641?v=4)](https://github.com/chachanagov "chachanagov (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![msmakouz](https://avatars.githubusercontent.com/u/67324318?v=4)](https://github.com/msmakouz "msmakouz (1 commits)")[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (1 commits)")

---

Tags

buggregatorbugregatorclicomposercomposer-packageconsoledebugdumphacktoberfestphpsentrysmtpcliconsolehelperdevdebugdumpserverWebSocketssentrydumpersmtpbinary dumpFibers

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/buggregator-trap/health.svg)

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

###  Alternatives

[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M719](/packages/psy-psysh)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[alecrabbit/php-console-spinner

Extremely flexible spinner for \[async\] php cli applications

24032.0k2](/packages/alecrabbit-php-console-spinner)

PHPackages © 2026

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