I am using Xdebug to analyze my Laravel code. I use the trace and coverage function.
For coverage, I can config whitelist and exclude to configure what directory and file I want to analyze.
But for trace, I don't know how to configure the exclude directory. Like vendor
, I think they are no change, so I want to exclude them. I just want to focus on my code.
Do you know how I can configure trace exclude or blacklist?
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="true" colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false">
<filter>
<whitelist processUncoveredFilesFromWhitelist="false" addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">./../</directory>
<exclude>
<directory suffix=".php">./../vendor</directory>
</exclude>
</whitelist>
<blacklist>
</blacklist>
</filter>
</phpunit>
For removing things from traces, you can use Xdebug's xdebug_set_filter() function. There is an example in the manual, which reads as follows:
To exclude all files in the vendor sub-directory in traces:
Example:
<?php xdebug_set_filter( XDEBUG_FILTER_TRACING, XDEBUG_PATH_BLACKLIST, [ __DIR__ . "/vendor/" ] ); ?>
You need Xdebug 2.6 or later for this to work. You can either put this in your index.php
script, or otherwise in an auto_prepend script. The only important note is that this line needs to be run before the include/calls within the /vendor/
folder are executed.
FWIW, In Xdebug 3, XDEBUG_PATH_BLACKLIST
will be renamed to XDEBUG_PATH_EXCLUDE
.