VSCode xDebug PHP API configuration - php

Hi i have problem with configuring xDebug with VSCode i am using OS X
launch.json
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
}
php.ini
[xDebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.idekey=SOMEKEY
xdebug.remote_autostart=1
php -v
PHP 7.1.23 (cli) (built: Nov 7 2018 18:20:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
Can you help me please?

Related

VSCode and Xdebug on a Laravel Lighthouse Windows environment setup

I'm trying to set up Xdebug to work in VSCode on a Windows environment with a Lighthouse / Laravel based server. My VSCode settings look like this
{
// 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": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
I've also tried adding a pathMappings to there with no luck
"pathMappings": {
"/graphql": "${workspaceRoot}/public"
}
I've followed https://laracasts.com/series/visual-studio-code-for-php-developers/episodes/13 and added all there suggested configurations. When I type php -v
PHP 7.4.10 (cli) (built: Sep 1 2020 16:52:21) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.0, Copyright (c) 2002-2020, by Derick Rethans
I do see Xdebug installed.
My php.ini looks like this
[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_host=localhost
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\tools\xdebug.log"
Any advice would be greatly appreciated
For anyone else with a similar problem just needed to upgrade my php.ini.
[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request=yes
xdebug.idekey=VSCODE
Ended up something like this not even sure if the idekey is even necessary now.
That and change the port to 9003 as that changed in version 3 apparently.

XDebug never recognise the stops put in php file in vscode

I am trying to debug my php code for the drop downs. I have already gone through other posts on Stackoverflow but still not able to solve the issue.
I have extension installed for php debug, changed the settings in php.ini, launch.json. What else should I do?
launch.json file
{
"version": "2.6.0",
"configurations": [
{ "name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 3000,
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 3000
}
]
}
php.ini
[XDEBUG]
zend_extension="C:\PHP 7.0v\v7.0\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.show_local_vars = 1
xdebug.remote_connect_back = 1
xdebug.remote_handler = dbgp
;xdebug.remote_host = 127.0.0.1 before
xdebug.remote_host = 10.176.17.108
xdebug.remote_port = 3000
xdebug.remote_mode = req
[MYSQL]
Results for php -v:-
C:\Users\T0209964\Downloads\MDB-Free_4.8.1>php -v
PHP 7.0.30 (cli) (built: Apr 24 2018 16:30:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
Everything looks fine. Try to enable logging in launch.json by adding "log": true and in xdebug config by adding xdebug.remote_log=/var/log/xdebug.log. Probably you will be able to see whats wrong.
I'm not sure that can be an issue but I'm also use option xdebug.idekey=VSCODE for configuration xdebug with vscode.
Also make sure you're using that php.ini which you're expected (eg. by running <?php phpinfo();)

VSCode + Xdebug + PHP configuration

I'm trying to set up Xdebug with VScode, but whenever I set breakpoints it's just ignoring it.
I installed https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug and followed the instructions (Windows), I also used the Xdebug Wizard, here is my configuration :
Vscode - launch.json
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
php.ini
zend_extension = D:\wamp\bin\php\php7.1.16\ext\php_xdebug-2.6.1-7.1-vc14.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_log=D:\wamp\logs\xdebug.log
Note: I can't find any logs, I probably didn't set it correclty but I don't know how to make it work either
php -v
$ php -v
PHP 7.1.16 (cli) (built: Mar 28 2018 21:27:36) ( ZTS MSVC14 (Visual C++ 2015) x8
6 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Thank you for reading !
I believe you may need the following in your php.ini:
xdebug.remote_connect_back=1
See the xdebug.ini for WPLib Box’s PHP container which definitely works with XDEBUG and VS Code.

Setup Xdebug for Laravel on Windows

Now I am learning Laravel, but the problem is: when trying to debug blade.php code it does not work, dont hit the breakpoin
Do you know how to make Xdebug work with Laravel?
OS:
Windows 8.1
Code editor:
Visual Studio code
Route of the laravel project:
C:\Users\SleekBook\Proyectos\SistemaEquino
PHP path:
C:\Users\SleekBook\scoop\apps\php\7.2.5\php.ini
PHP.ini configuration:
zend_extension = "C:\Users\SleekBook\scoop\apps\php\7.2.5\php_xdebug-2.6.0-7.2-vc15-x86_64.dll"
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.show_local_vars = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
The server local its online
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}

Xdebug - Debug adapter process has terminated unexpectedly

I am using Visual Studio Code:
I have also installed the PHP Debug Extension Version 1.12.1. My PHP Version is:
>php --version
PHP 7.1.8 (cli) (built: Aug 1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
I have configured xdebug following the instructions on the PHP Debug plugin.
My settings inside my php.ini look like the following:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll"
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
When running phpinfo(); my xdebug shows correctly:
My launch.json file looks the following:
{
// 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": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
However, when running the configuration I get:
The error log looks like the following:
messageService.ts:126 Debug adapter process has terminated unexpectedly
e.doShow # messageService.ts:126
e.show # messageService.ts:105
_.onServerExit # rawDebugSession.ts:535
(anonymous) # rawDebugSession.ts:449
emitTwo # events.js:111
emit # events.js:194
__dirname.ChildProcess._handle.onexit # internal/child_process.js:215
Any suggestions what might be wrong with debugging?
I appreciate your replies!
Your vscode config looks fine (at least for pure-Windows PHP debugging). Your php.ini Xdebug config is unnecessarily filled with unimportant stuff (at least for debugging).
Get rid of the whole thing and try this minimal xdebug config:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
Then (if you use Chrome) you can use this extension to manage enabling/disabling debug sessions: Xdebug helper
Note: This is for debugging via browser - Chrome. I guess some equivalent plugin should exist for Firefox, but I haven't tried that. If you use Linux or WSL on Windows 10, you can enable debugging session by setting the proper environment variable like export XDEBUG_CONFIG="idekey=whatever" in Linux terminal. I suppose some equivalent exists with pure Windows command-line, but I haven't tried that, either.

Categories