Attention "dusty"!
This article is already a little outdated and may contain information that no longer corresponds to the current status of the topic.
Xdebug is a great debugging tool for PHP developers, but in the past it has also caused some headaches. This has come to an end with the release of Xdebug 3! The new version is not only easier to configure, but also offers a big performance boost that improves the developer experience. In this article, we present all the new features in Xdebug 3 that you should definitely know about.
Upgrade from Xdebug 2 to Xdebug 3
If you are already using Xdebug 2 and want to upgrade to version 3, you can find the official documentation here. We will also discuss the most important steps and changes below.
Significant performance boost
Xdebug 2 sometimes causes headaches as it has a negative impact on the performance of the PHP application. However, the first benchmark tests with Xdebug 3 provide hope: depending on the configuration, Xdebug 3 is up to 34% faster during debugging and up to 99% faster when the Xdebug extension is installed but not activated.
New configuration: Xdebug modes
Xdebug 3 also makes configuration much easier. The sometimes confusing concepts of "xdebug.remote_enabled" ," xdebug.profiler_enabled" , "xdebug.remote_autostart" & co. are no longer necessary. Only one line remains: "xdebug.mode=debug" . These changes must be made in php.ini.
Now in Xdebug 3, apart from "debug", there are other modes that enable different debugging functionalities. The most important are
- off - The extension is installed but not activated
- develop - Switches the development aids on, which enable comprehensible error messages, for example
- coverage - especially interesting if code with coverage reports runs with PHPUnit
- debug - Enables step debugging
- gcstats - Collects statistics about PHP's carbage collectionmechanism
- trace - Enables the function trace feature, with which all function calls including parameters etc. can be collected
It is not necessary to write a separate line for each of these settings. The required modes can simply be separated by a comma.
For the average project, not all of these modes are necessary and "xdebug.mode=debug" will be sufficient in most cases.
New default port
Care should be taken with the port in the new version. In Xdebug 3, the default port has changed from 9000 to 9003, which must be adjusted accordingly in the IDE settings. Instructions for setting up Xdebug in PhpStorm can be found here.
PHP 8 Support
PHP 8 was released on 26.11 and brings some new features with it. In contrast to version 2, Xdebug 3 supports PHP 8.
Xdebug 3: Faster, lighter, better
Xdebug takes a big step forward with version 3 and becomes more user-friendly for PHP developers. In addition to a simplified configuration, Xdebug 3 offers a significant performance boost and supports PHP 8. We therefore believe that the upgrade is worthwhile for every developer!