# Debugger

> Section in “Introduction › Behind the Scenes” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/introduction/behind-the-scenes/debugger/>

PHP 5.6 was the first version of PHP to ship with `phpdbg`, an interactive debugger that can be used locally on the command-line as well as remotely via client applications. It is inspired by GDB, the de facto standard for debugging UNIX programs, and can be invoked using the `phpdbg` command.

When you download PHP 7 from `https://php.net` and build the PHP interpreter yourself, `phpdbg` is not built by default. You need to pass the `--enable-phpdbg` option to `configure` to enable it. If you use a package provided by the vendor of your Linux distribution to manage your PHP environment, then you probably need to install a separate package to get the `phpdbg` binary.

For PHP 7, `phpdbg` has been expanded with code coverage functionality. This means that you can now collect, process, and report code coverage data with PHPUnit, for instance, without having to install a third-party extension such as Xdebug or PCOV. To use PHP 7’s built-in code coverage functionality with PHPUnit, just invoke PHPUnit using the `phpdbg` binary instead of the `php` binary as shown below:

    $ phpdbg -qrr phpunit.phar --coverage-clover coverage.xml tests
    PHPUnit 9.2.2 by Sebastian Bergmann and contributors.

    ............................................

    Time: 00:01.788, Memory: 6.00 MB

    OK (44 tests, 70 assertions)

    Generating code coverage report in Clover XML format ... done

The `-qrr` command-line option for the `phpdbg` invocation shown above instructs `phpdbg` to execute a script and quit after the execution finished without debugging the PHP code that is executed.

---

Previous: [Bytecode Optimization](https://php7explained.com/introduction/behind-the-scenes/bytecode-optimization/index.html.md) | Next: [Getting PHP 7](https://php7explained.com/introduction/getting-php-7/index.html.md)
