Debugging PHP, from NetBeans using XDebug and XAMPP - php

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

Related

How to use visual studio 19 to debug a php app running on an azure Ubuntu VM

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.

Can't figure out to let Xdebug work in combination with PhpStorm and 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

Waiting for connection(netbeans-xDebug)-php-XAMPP

I tried to use netbeans to debug php program. And the xdebug is not working. What I have tried is
Go to http://xdebug.org/wizard.php to analyse my phpinfo() .
I downloaded php_xdebug-2.4.0rc2-5.6-vc11.dll and put it into C:\xampp\php\ext
I also modified php.ini(I am sure it is the correct file) like
zend_extension = "C:\xampp\php\ext\php_xdebug-2.4.0rc2-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 = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
I also checked port 9000. When netbeans does not debug, I enter netstat -ano | find "9000" from cmd. It comes nothing. While I start debuging throuh netbeans, it comes as the picture below
So I thought that the netbeans can interactive with xDebug through port 9000 properly.
The problem might be ip address. So I try to use my ipv4 address(cmd-ipconfig) instead of 127.0.0.1,not working. And also "localhost", not working neither.
I realize that I am working on the university with vpn and maybe the problem comes from firegate or antivirus software. But I can not shut down any of them because I am not the system administrator.
How to deal with this situation? Any help?
I spent entire day for this.
Problem solved. I tried all but nothing works. Finally I unistalled XAMPP and followed the steps from http://xdebug.org/wizard.php. My final xDebug part in php.ini file is(only uncommented content)
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.4.0rc2-5.6-vc11.dll"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port=9000
I thought my problem casued by the configuration in apach server. Because the first time when I wanted to start Apach server from XAMPP control panel, it said error because of port block. So I changed the port number instead of using the default port. And after I reinstalled the XAMPP control panel, I restarted the computer and started Apach server immediatelty to make sure nothing else occupied the port. And all works great. So it might be the problem. Hope useful.

Debugging with setting Xdebug and PHPStorm

i'm using PHPStorm and trying to run Xdebug according this video https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/20?autoplay=true.
First part works perfectly (https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/19?autoplay=true), but i'm stuck at second one.
Port 9000 was not working, so i changed it to 10000.
I configured PHP Web Application configuration
and after I press debug button, web is blank
and still loading and PHPStorm is waiting for incoming connection.
I have checked "can accept external connection" at PHP - Debug - Xdebug and xdebug in php.ini configured like this:
[XDebug]
zend_extension="/usr/local/Cellar/php56-xdebug/2.3.3/xdebug.so"
xdebug.remote_enable = 1
xdebug.cli_color = 1
xdebug.show_local_vars = 1
xdebug.remote_port = 10000
xdebug.remote_host= localhost
xdebug.remote_autostart = 1
xdebug.remote_log="/usr/local/tmp/xdebug.log"
xdebug.idekey = "PHPSTORM"
xdebug.ide_key = "PHPSTORM"
xdebug.profiler_enable = 1
xdebug.profiler_output_dir="/usr/local/tmp/xdebug-profiler"
xdebug.profiler_enable_trigger = 1
I tried to validate web server with this result:
I was googling and trying solve this for 6 hours, try to help me please, i`m kind of dummy in this.
Using OS X El Capitan.
I can debug single script, but not a whole website.
When i run this directly online-chef.dev:10000, it says ERR_CONNECTION_REFUSED.
"online-chef.dev" is at local virtual host.
What I am doing wrong?
Thank you so much!
You are tried to debug web page through xdebug. For debug javascript you need install browser extention. This is manual for javascript debugging.
For javascript debug get current extention port and enter in this place:
For XDebug i don't want always click debug button, so i simple enable listen connections. This is manual for XDebug from JetBrains.
Here is my xdebug config that working with listen connections.
xdebug.idekey = "PHPSTORM"
xdebug.remote_port = 9001
xdebug.remote_mode = "req"
xdebug.remote_host = 10.0.2.2
xdebug.remote_handler = "dbgp"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.extended_info = 1
So, when i need debug javascript i click debug button. When i need debug php i just put breakpoint.
First set up debugging instruments often is hard, but it's pays off.

It is possible avoid only external connections to my xdebug with Ngnix and PHPStorm?

I have a development environment in my computer, I use nginx and PHPStorm with Xdebug for my debugging, I need to debug in my environment but other people also connects to my machine for testing purpose, it is possible that when I active my debug this only affect me and not for they?
Update:
My xdebug.ini looks like this:
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.idekey = PHPSTORM
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_handler = dbgp
xdebug.remote_port = 9001
xdebug.remote_autostart = On
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp
xdebug.remote_host = localhost
The key here is the setting: xdebug.remote_host. The default value is localhost, which guarantees that Xdebug only contact a debug client which is listening on your localhost and configured port
More detail: Xdebug Settings Document
& Remote Debugging Document

Categories