|
| 1 | +# Trap — Commands |
| 2 | + |
| 3 | +## `run` |
| 4 | + |
| 5 | +### Description |
| 6 | + |
| 7 | +The `run` command starts the Trap server, which listens for debug information on specified ports and |
| 8 | +processes it using configured senders. |
| 9 | + |
| 10 | +### Simple Example |
| 11 | + |
| 12 | +```bash |
| 13 | +vendor/bin/trap run |
| 14 | +``` |
| 15 | + |
| 16 | +### Arguments and Options |
| 17 | + |
| 18 | +| Option | Short | Description | Default | |
| 19 | +|------------|-------|---------------------------------------------------------|--------------------------| |
| 20 | +| `--port` | `-p` | Port(s) to listen on (can be specified multiple times) | `1025, 8000, 9912, 9913` | |
| 21 | +| `--sender` | `-s` | Sender type(s) to use (can be specified multiple times) | `console` | |
| 22 | +| `--ui` | - | Enable web UI (with optional port specification) | `false` | |
| 23 | + |
| 24 | +### Port Configuration Details |
| 25 | + |
| 26 | +By default, Trap runs on multiple ports simultaneously: `1025, 8000, 9912, 9913`. All ports listen for the same data, |
| 27 | +but this multi-port setup makes it compatible with various debugging tools that have their own default ports: |
| 28 | + |
| 29 | +- Port `1025`: Default SMTP port for email testing |
| 30 | +- Port `8000`: Used for HTTP dumps |
| 31 | +- Port `9912`: Default port for Symfony VarDumper |
| 32 | +- Port `9913`: Default for Monolog socket handler |
| 33 | + |
| 34 | +If you want to listen on just one specific port, you can specify it: |
| 35 | + |
| 36 | +```bash |
| 37 | +vendor/bin/trap run -p 8000 |
| 38 | +``` |
| 39 | + |
| 40 | +This will make Trap listen only on port `8000`. |
| 41 | + |
| 42 | +### Examples |
| 43 | + |
| 44 | +Start with default settings: |
| 45 | + |
| 46 | +```bash |
| 47 | +vendor/bin/trap run |
| 48 | +``` |
| 49 | + |
| 50 | +Listen on specific ports: |
| 51 | + |
| 52 | +```bash |
| 53 | +vendor/bin/trap run --port=8888 |
| 54 | +# or |
| 55 | +vendor/bin/trap run -p 8888 |
| 56 | +``` |
| 57 | + |
| 58 | +Listen on multiple ports: |
| 59 | + |
| 60 | +```bash |
| 61 | +vendor/bin/trap run --port=8888 --port=9999 |
| 62 | +# or |
| 63 | +vendor/bin/trap run -p 8888 -p 9999 |
| 64 | +``` |
| 65 | + |
| 66 | +Enable the web UI on default port: |
| 67 | + |
| 68 | +```bash |
| 69 | +vendor/bin/trap run --ui |
| 70 | +``` |
| 71 | + |
| 72 | +Use environment variables for configuration: |
| 73 | + |
| 74 | +```bash |
| 75 | +TRAP_TCP_PORTS=8888,9999 TRAP_UI_PORT=8080 vendor/bin/trap run --ui |
| 76 | +``` |
| 77 | + |
| 78 | +### Available Senders |
| 79 | + |
| 80 | +Trap supports multiple methods ("senders") for outputting the debug information, allowing you to choose where your debug |
| 81 | +dumps are sent: |
| 82 | + |
| 83 | +- **Console**: Outputs dumps directly in the console. |
| 84 | +- **Server**: Sends dumps to a remote Buggregator server for centralized management and review. |
| 85 | +- **File**: Saves dumps to a file, useful for auditing or detailed offline analysis. |
| 86 | + |
| 87 | +By default, dumps are displayed in the console. However, you can configure multiple senders simultaneously to suit your |
| 88 | +workflow and requirements. For example, to use the console, file, and server senders together: |
| 89 | + |
| 90 | +| Sender | Description | |
| 91 | +|----------------|--------------------------------------------------| |
| 92 | +| `console` | Outputs debug information to the console | |
| 93 | +| `file` | Writes events to files in JSON format | |
| 94 | +| `file-body` | Writes event body content to separate files | |
| 95 | +| `mail-to-file` | Stores received emails to files | |
| 96 | +| `server` | Forwards events to a Buggregator server instance | |
| 97 | + |
| 98 | + |
| 99 | +```bash |
| 100 | +vendor/bin/trap run --sender=console --sender=file |
| 101 | +``` |
| 102 | + |
| 103 | +## `test` |
| 104 | + |
| 105 | +### Description |
| 106 | + |
| 107 | +The `test` command sends various types of test data to the Trap server to verify that it's working correctly. This |
| 108 | +includes XHProf data, var dumps, emails, Sentry reports, and binary data. |
| 109 | + |
| 110 | +### Simple Example |
| 111 | + |
| 112 | +```bash |
| 113 | +vendor/bin/trap test |
| 114 | +``` |
| 115 | + |
| 116 | +### Arguments and Options |
| 117 | + |
| 118 | +The `test` command doesn't accept any arguments or options. |
| 119 | + |
| 120 | +### Example |
| 121 | + |
| 122 | +To send test data to a running Trap instance: |
| 123 | + |
| 124 | +```bash |
| 125 | +# First, start the trap server in one terminal |
| 126 | +vendor/bin/trap run |
| 127 | + |
| 128 | +# Then, in another terminal, run the test command |
| 129 | +vendor/bin/trap test |
| 130 | +``` |
| 131 | + |
| 132 | +This will: |
| 133 | + |
| 134 | +1. Send XHProf profiling data |
| 135 | +2. Execute various `trap()` dumps |
| 136 | +3. Send test emails (both simple and multipart) |
| 137 | +4. Send Sentry store and envelope data |
| 138 | +5. Send binary data |
| 139 | + |
| 140 | +--- |
| 141 | + |
| 142 | +## `joke` |
| 143 | + |
| 144 | +### Description |
| 145 | + |
| 146 | +The `joke` command prints a random joke using the trap framework. It's a fun addition that also demonstrates the trap |
| 147 | +functionality. |
| 148 | + |
| 149 | +### Simple Example |
| 150 | + |
| 151 | +```bash |
| 152 | +vendor/bin/trap joke |
| 153 | +``` |
| 154 | + |
| 155 | +### Arguments and Options |
| 156 | + |
| 157 | +The `joke` command doesn't accept any arguments or options. |
| 158 | + |
| 159 | +### Example |
| 160 | + |
| 161 | +To display a random joke: |
| 162 | + |
| 163 | +```bash |
| 164 | +vendor/bin/trap joke |
| 165 | +``` |
| 166 | + |
| 167 | +The joke output will be displayed using the same output mechanism as other trap messages, which can be a good way to |
| 168 | +verify that your trap setup is working correctly in a lightweight manner. |
| 169 | + |
| 170 | +## Environment Variables |
| 171 | + |
| 172 | +Trap can be configured using environment variables: |
| 173 | + |
| 174 | +| Variable | Description | Default | |
| 175 | +|-----------------------------|--------------------------------------------|-------------------------------------| |
| 176 | +| `TRAP_TCP_PORTS` | Comma-separated list of ports to listen on | `1025,8000,9912,9913` | |
| 177 | +| `TRAP_TCP_HOST` | Host interface to bind to | `127.0.0.1` | |
| 178 | +| `TRAP_TCP_POLLING_INTERVAL` | Socket polling interval in microseconds | `1000` | |
| 179 | +| `TRAP_UI_PORT` | Web UI port | `8000` | |
| 180 | +| `TRAP_UI_HOST` | Web UI host interface | `127.0.0.1` | |
| 181 | +| `TRAP_MAIN_LOOP_INTERVAL` | Main loop interval in microseconds | `100` | |
| 182 | +| `TRAP_XHPROF_PATH` | Path to XHProf files | Read from PHP's `xhprof.output_dir` | |
| 183 | +| `TRAP_XHPROF_SORT` | XHProf edges sorting algorithm (0-3) | `3` | |
0 commit comments