Comments (1)
On mac I'm able to debug my phpunit tests running in docker container with the setup below
My xdebug.ini
[xdebug]
xdebug.mode=debug,profile,trace,develop
xdebug.client_port=9003
xdebug.client_host=host.docker.internal
xdebug.start_with_request=trigger
xdebug.trigger_value=vscode
xdebug.log_level=0
In my settings.json
I have
{
"phpunit.command": "docker exec -t app /bin/sh -c",
"phpunit.php": "XDEBUG_MODE=debug XDEBUG_TRIGGER=vscode XDEBUG_SESSION=vscode php",
"phpunit.phpunit": "/var/www/html/vendor/phpunit/phpunit/phpunit",
"phpunit.args": [
"-c",
"phpunit.xml"
],
"phpunit.paths": {
"${workspaceFolder}": "/var/www/html"
},
}
app
is container_name
from docker-compose.yml
services:
app:
container_name: app
Note that because I use xdebug.trigger=vscode
I have to set XDEBUG_*
variables for "phpunit.php": "..."
.
I use xdebug/vscode-php-debug extension with following launch.json
{
"name": "xdebug",
"type": "php",
"request": "launch",
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"skipFiles": [
"**/vendor/composer/ClassLoader.php",
"**/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php",
],
"xdebugSettings": {
"max_depth": 5,
"max_children": 100,
"max_data": 10000
}
},
To start debugging test I first start the debugger with F5
and then I press play to execute test.
If debugging is still not working then go to Output
panel in vscode and find phpunit
in the dropdown. There you can see which command is being executed when you press play. You can copy the command from Output
and run that manually in your terminal. You will have to wrap anything after /bin/sh -c ...
in double quotes /bin/sh -c "..."
. Tweak the command until you get the breakpoint working and then copy the working command back into the settings above
I hope this helps
from vscode-phpunit.
Related Issues (20)
- cannot debug and be stopped
- Tests status not updating in tests explorer HOT 3
- phpunit.paths setting doesn't resolve path mapping HOT 6
- docker: invalid reference format HOT 3
- Tests are not being detected
- json5 to jsonc in README.md to match vscode's settings.json format
- Problem with path to the test file HOT 2
- Command-line options are not recognized by phpunit HOT 1
- Extension causes high cpu load
- Editor is read-only because the file system of the file is read-only HOT 4
- Not showing all test classes HOT 2
- Could not open input file on Mac HOT 2
- Issue when cwd has spaces in directory name HOT 1
- Option to Remove --teamcity Command-line Argument HOT 1
- phpunit.paths mapping not working with warden/den HOT 1
- Don't show test as failed when failOnRisky and failOnWarning are set to false HOT 1
- Feature request: adding exclaimation mark to test with warnings to help spotting them
- Extension does not work with PHP 8.3
- Spawn Error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-phpunit.