I am trying to use Xdebug for my Drupal project debugging. In some documentations, I saw that the Xdebug is able to find memory leaks as well. I tried to use that facility. But I am not getting any logs regarding that.
I configured my 20-xdebug.ini as follows
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir = "/home/myname/Desktop/xdebug/"
xdebug.trace_output_dir="/home/myname/Desktop/xdebug/"
xdebug.remote_log="/home/myname/Desktop/xdebug/xdebug.log"
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.trace_format=1
xdebug.idekey=netbeans-xdebug
xdebug.remote_autostart=1
I am able to connect NetBeans with Xdebug and I can go through each break points. But there are no logs regarding this in the /tmp folder and there are no log files in the above given paths as well.
Am I doing something wrong? Please assist me on this.
maybe you need
xdebug.show_mem_delta = 1
xdebug.show_mem_delta
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's human-readable
generated trace files will show the difference in memory usage between
function calls. If Xdebug is configured to generate computer-readable
trace files then they will always show this information.
Related
How can I get Xdebug v3.1.1 to display output "beautified" with PHP 8.1?
Is it necessary to turn on some specific Xdebug configuration option in php.ini?
This is how I need the output on screen to look like:
And this is how it currently looks like:
This is my current Xdebug configuration in php.ini for PHP 8.1:
[XDebug]
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
xdebug.mode=debug
xdebug.profiler_append = 0
xdebug.start_with_request=trigger
xdebug.remote_handler = dbgp
xdebug.start_with_request=yes
xdebug.log_level = 0
xdebug.force_display_errors=1
xdebug.force_error_reporting=1
xdebug.show_error_trace=1
xdebug.show_exception_trace=1
xdebug.cli_color = 1
xdebug.trace_format=1
xdebug.show_local_vars=1
You need to also list develop in the debug mode value:
xdebug.mode=debug,develop
https://xdebug.org/docs/all_settings#mode
https://xdebug.org/docs/develop#stack_trace
P.S. Rather unrelated... but better stick to the new Xdebug port (9003) and not old one 9000 -- it was changed for a reason (as it was often conflicting with php-fpm that also uses the same TCP 9000 port by default).
Sure, if it works then do not change .. but it's better to use safer option (may save a lot of troubleshooting time on a new machine/different setup in a future).
ALSO: xdebug.remote_handler = dbgp -- this is Xdebug v2, does nothing in Xdebug 3. And dbgp is the ONLY possible value anyway...
I’ve configured the virtual machine, installed apache2, php, MySQL and xdebug. The website works and I’ve configured VS but nothing happens when I debug the project in VS.
Note I have to use a VM because there is some trickery that is being done with open VPN.
I am no expert with PHP as I come from the ASP.NET world and I have never used Xdebug before.
I've been asked to add some additional information but the /etc/php/7.2/apache2/php.ini file is too large to add into this post. If you want some more information please ask for a section and I will post it.
In the mods-available folder is an xdebug.ini file that contains:
zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
I've also set up an inbound rule in Azure for the server to a allow port 9000.
When running VS I have set up the Server URL and specified Xdebug Port 9000.
DBGp proxy is not set.
Thank you
Tim
I finally managed to get something to work.
I updated the xdebug.ini like this:
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 86.180.220.70
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
xdebug.idekey = "php-vs"
And, crucially, opened the firewall on my machine for port 9000.
Now I can't seem to set any break points in php that actually hit.
I'm assuming this has something to do with path mapping - plenty of stuff on google for Code but little if nothing for Visual Studio...
I have to say the documentation for doing things like this is SHOCKINGLY bad. Most examples are for a Windows php.ini file, not for Linux. If your a seasoned php programmer your probably used to it but for a newbie like me its an absolute minefield.
I have followed this document:
This is my php.ini
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000
I am running Apache using XAMPP on port 9000:
from NetBeans when I do: Debug -> Debug Project
I get the following:
Port 9,000 is already in occupied. Configure the IDE to use another
port?
XAMPP is the software that is using port 9000 thousand. What do I need to do here? Should I change the XDebug port to 9001? Tools -> Options:
If I do this, I would also need to change php.ini and change the XDebug port to 9001.
Or should I keep using port 9000? I have been different settings, but not able to hit my break point.
I have been using Netbeans for years to code PHP and xdebug has always been a pain. I cant even give you any pointers.
But I switched last year to VS code and I can honestly say that it improved my code, and xdebug is actually easy to connect, and fun to use.
I recommend you give it a try.
This is how I got the debugger running:
When prompted with:
Port 9,000 is already occupied Configure the IDE to use another port?
Click Yes (alternatively you can open the setting from Tools -> Options: Choose PHP -> Debugging)
Set debugger Port to 9001.
update php.ini to have port 9001
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
Restart XAMPP
I followed this steps, recommended by Xdebug based on phpinfo():
Download php_xdebug-2.4.0rc4-5.6-vc11.dll
Move the downloaded file to C:\xampp\php\ext
Update C:\xampp\php\php.ini and change the line
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll
Restart the web server
I also unchecked the 'ignore external connections through unregistered server configurations in PhpStorm. In PhpStorm port 9000 is configured. This port isn't used by an other application.
In the php.ini file I listed the following configuration:
[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.trace_output_dir = "C:\xampp\tmp"
The DLL file exists.
I also enabled the debug functionality in chrome via the xdebug addon.
Which step do I miss?
You're probably going to want to set xdebug.remote_enable = 1 or the remote debugging will be disabled.
Also, set the remote debug port phpStorm is set to use:
xdebug.remote_port=9000 (I'm assuming port 9000, it's the default, but check phpstorm)
To debug every request (if you don't have the chrome plugin for a browser for example) use xdebug.remote_autostart = on
I have encounter one problem when I am using PHPStorm 8 under Mac OS, I make some PHP files and I want to debug, but seems my XDebug does not work at all. All my break points just are ignored. I checked my configuration twice and I have tried the online tools on http://xdebug.org/wizard.php
Here's my configuration of my php.ini.
[XDebug]
;zend_extension=opcache.so
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
xdebug.idekey = "PHPSTORM"
and I also validated on the phpstorm like that.
I don't know why is that? Anybody has any idea?
Jason