XDebug Installation for Windows
Prerequisites
This guide assumes you have:
- Windows operating system
- PHP installed
- VS Code or similar text editor
- Administrator access to modify system files
Installation Process
Generate PHP Information
In a terminal window:
php -i > phpinfo.txtUse the XDebug Installation Wizard
- In VS Code, open the
phpinfo.txtfile, (vscode:ctrl+pthen typephpinfo.txt) - Select all text (
Ctrl + A) and copy it (Ctrl + C) - Visit the XDebug Wizard
- Paste the text into the input field (
Ctrl + V) - Click "Analyse my phpinfo() output" at the bottom of the page
Follow the Installation Steps
You will receive a summary with installation instructions:
- Download the DLL file by clicking on the provided link
- Move the downloaded file to the PHP extensions directory (commonly
C:\Program Files\php\ext) - Rename it to
php_xdebug.dll
Configure PHP.ini
- In Windows Search, type "Notepad"
- Right-click on Notepad and select "Run as administrator"
- In Notepad, press
Ctrl + Oand navigate toC:\Program Files\php - Open the
php.inifile - Press
Ctrl + Fto search formemory_limit - Check if the value is at least
512M(e.g.,memory_limit = 512M)- If it's lower (like
128M), change it tomemory_limit = 512M - This ensures enough memory for PHP when running tests with coverage
- If it's lower (like
- At the end of the file, add the following lines:
[XDebug]
zend_extension = xdebug
xdebug.mode = coverage,develop,debug- Make sure to delete the
phpinfo.txtfile, as it is no longer necessary.
Run All Integration Tests with Coverage
Open a terminal and navigate to your backend directory:
cd backend
./vendor/bin/pest --testsuite=Integration --stop-on-failure --coverage --coverage-textThis will generate a coverage report based on the files specified in the <source> section of your phpunit.xml configuration file.
Running One Specific Test File
To run tests on a specific file instead of the entire test suite. Use the path to the specific test file. For example:
cd backend
./vendor/bin/pest tests/Integration/app/Actions/Model/CareType/UpdateCareTypeActionTest.php --stop-on-failure --coverage --coverage-textTroubleshooting
Coverage Issues
No Coverage Report Generated If tests run but no coverage information appears:
Check that XDebug is properly installed and loaded. Run in a terminal:
php -vYou should see "with Xdebug" in the output
ERROR
If you encounter this error: Unable to get coverage using Xdebug. Did you set Xdebug's coverage mode?
This means that XDebug is installed but not properly configured for code coverage. Check that:
- You've added the
xdebug.mode = coverage,develop,debugline to yourphp.inifile - The line is not commented out (doesn't have
;at the beginning)