I am using Visual Studio Code with the PHP Debug extension to debug a Laravel project. But some breakpoints are ignored and I cannot figure out why. I insist on the fact that not all breakpoints are ignored. For instance all breakpoints at method declarations are ignored but those at variable declarations are hit.
The Xdebug part of my php.ini:
xdebug.profiler_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
This is my launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9001,
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
What I tried:
- Changing the default port 9000 to 9001
- Uninstalling and reinstalling the PHP debug extension (you never know)
Example: the "•" indicates a line breakpoint. All the breakpoints in the code sample below are ignored.
public function testCreateWhenAllParametersAreCorrectlySpecifiedReturnsCompany()
{
• $attributes = [
'business_name' => 'DANONE'
];
$address = factory(Address::class)->create();
$company = Company::create($attributes, $address);
$this->assertInstanceOf(Company::class, $company);
$this->assertDatabaseHas('companies', [
• 'address_id' => $address->id,
'business_name' => 'DANONE'
]);
}
How to get Xdebug with Visual Studio Code hitting all breakpoints or is this normal behaviour? Thank you in advance for your help.
Update #1 (08/07/2019)
The Zend extension path is specified in my php.ini like below.
zend_extension = "/usr/local/Cellar/[email protected]/7.2.18/pecl/20170718/xdebug.so"
And I tried to add php.validate.executablePath in my settings.json.
Update #2 (08/08/2019)
According to the comments and the answers at the time of this update, Xdebug ignoring some lines is the normal behavior. My questions then are why are some lines ignored? What kinds of lines are ignored? Is there an official list?




xdebug_break();in your code and see if it will trigger it. P.S. I suggest placing breakpoints on actual lines of code and they better be single liners / simple instructions. Due to the way how PHP generated byte code, some breakpoints have different line that you would expect (e.g. multi line array declaration -- it would be somewhere in the middle). P.P.S. Maybe VSC does not support "method breakpoints" (when it's placed on the function declaration line). - LazyOne