Xdebug 3 is here: Massive performance increase, simpler config, and PHP 8 support
Tags: news, php, webdev, laravel
Published: 2020-11-25 16:43:24

If you're using Xdebug for PHP debugging, there's a new version that just released today: Xdebug 3. Check out the [announcement](https://xdebug.org/announcements/2020-11-25)! Promising massive performance boosts, a simpler configuration paradigm, and support for the upcoming (tomorrow!) PHP 8.0 release.

{% twitter 1331621484607967232 %} 

## Upgrading

To read about how to upgrade from Xdebug 2 to Xdebug 3, [read the upgrade guide](https://xdebug.org/docs/upgrade_guide). Some highlights below:

## Performance

The [benchmarks of Xdebug 3](https://php.watch/articles/xdebug2-vs-3-benchmark?r) have shown that Xdebug 3 is **34% faster** for step debugging, and **25% faster** when in `develop` mode. In addition, if you have the Xdebug extension installed, but aren't actively using it (features are disabled), Xdebug 3 is over **99% faster** than Xdebug 2.

# Configuration highlights

One of the big shifts with Xdebug 3 is the introduction of the `xdebug.mode` ini setting. If you've ever struggled getting just the correct incantation or flavor of Xdebug ini settings to get debugging working, feast your eyes on this thing of beauty:

```
xdebug.mode=debug
```

That's it. No more deciphering if you need `remote_enable` on, `profiler_enable` on, or trying to remember what exactly `remote_autostart` does. 

## Multiple Xdebug modes

You can combine Xdebug modes together with a comma. These other modes for `xdebug.mode` are:

- `off` Everything is—ahem—off. This means you can have the extension installed but disabled, and a negligible performance hit. ✨ I'm guessing you can't really combine this with the other modes? 🤷‍♂️
- `develop` Turns on [development aids](https://xdebug.org/docs/develop). If you like stack traces or if `var_dump()` is your friend, you'll want this setting.
- `coverage` If you're running code coverage reports with PHPUnit, turn this on.
- `debug` Enables step debugging. 😋
- `gcstats` Collect statistics about PHP's garbage collection mechanism. 🗑
- `profile` Use this to analyze performance with tools like KCacheGrind. 
- `trace` Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file.

Time will tell, but I'm guessing `xdebug.mode` on most of my projects will be:

```
xdebug.mode=develop,debug,coverage
```

## Starting a step debug session

Remember the `XDEBUG_CONFIG="idekey=wtf"` days? No longer. Now it's simplified to an `XDEBUG_SESSION` environment variable to turn on step debugging. Set this environment variable to the key you'd like for that step debug session. 

```
XDEBUG_SESSION=wtf
```

## Step debugging? Port 9003

![Caution](https://dev-to-uploads.s3.amazonaws.com/i/91gka35xg2xwi74z2gjt.gif)

⚠️ **Heads up:** the default step debugging port has changed from port 9000 to port 9003. 

# Win, win, win: performance, simpler config, PHP 8 support

What's not to love about this release? I'm excited to be able to have the extension installed and available without a huge performance hit. I'm looking forward to simpler configuration. And tomorrow, PHP 8.0 will land, which is the first release to have [JIT compiling](https://dev.to/tugboatqa/php-8-0-is-almost-here-how-to-turn-on-jit-compiling-1l6l).