I have my 1and1 hosted web site. I've got server-side php I need to debug.
All I've found mentions running/installing xdebug when you have a local web server
with php and mysql on a local web server.
However, I'm using the remote web server hosted at 1and1 hosting.
I'm using and loving netbeans, wow great IDE.
Anyways, how (if it's even possible) can I install then use the xdebug
debugger to debug my php code running at 1and1 from within Netbeans?
I'm wondering if it is my hosting company (1and1) that has to have xdebug installed.
I'm running the latest version of Netbeans but when I press the debug button on
the toolbar I see an error message popup that says
"There is no connection from xdebug detected within 40 seconds. The reasons could be that xdebug is neither installed nor properly configured. Be sure that your php.ini file contains these entries:
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost (or hostname)
xdebug.remote_port=9000
So I searched my harddisk, and despite having installed the full Netbeans
IDE, I have no php.ini file.
So can I make xdebug work remotely, ie. can I debug my php code as it runs on the
remote 1and1 web server, using Netbeans and xdebug?
I've only been using Netbeans for 2 days and for all I know, xdebug is not even a part
of Netbeans. Reason I say that is, I can 'run' my php remotely just fine -- it executes on the remote 1and1 web server when I push 'run' inside Netbeans -- and then the client side output on my local machine is correct. But I cannot step into the code with xdebug by pressing the 'Debug' button on the Netbeans toolbar -- is it possible xdebug did not get installed correctly with Netbeans?
xdebug should be installed inside the php folder and of course the php folder is located on the server where php is installed... at your hosting provider.
I would not expect an hosting provider to install xDebug as it seems to me it would be a huge security hole.
xDebug is not part of Netbeans and it is not part of PHP by default.
Now, looking at things on a more positive viewpoint, if you are going to develop PHP, you NEED a local server. It's very unprofessional to develop code directly on the live server.
Grab a copy of xampp and install it on your computer. Grab a copy of xdebug and install it following the instructions. Restart Apache. There, now you have a testing server.
Once you have a complete set-up on your computer, copy your PHP application's folder inside the "htdoc" folder.
NOW, and only now, should you consider developing in PHP. Develop locally, on your own testing server, xdebug will work whenever you start a debugging session from inside Netbeans.
When everything works, upload your files on your hosted space.
Related
I'm new to VS Code and the php world. My experience is more with heavyweight IDE such as Visual Studio. However, I have a need to setup a php environment on my dev machine and am having some trouble getting it to work properly.
My environment is a Win 10 dev machine. I am using VS Code and php ver 5.5. I have properly installed the xdebug extension and verified it is properly installed. I have also installed the php-debug extension in VS Code.
The challenge I'm having and have been unable to find any useful information through google is launching the php website from within VS Code and then being able to debug it.
A few things I have tried, but haven't worked.
I installed the iis-express extension to VS Code which allows for running any folder through iis express. https://marketplace.visualstudio.com/items?itemName=warren-buckley.iis-express
This works, but the website doesn't display properly. IIS returns an error message saying the site is not properly configured. It's apparently missing a mapping or something along those lines.
I followed this blog. http://blog.denouter.net/2015/05/run-php-from-visual-studio-code.html and am able to run the website using the built in php web server.
Installed webmatrix and let the windows platform installer correctly install and wire up iis express to work with php. The same folder works fine when running from webmatrix.
Installed the php-debug extension to VS Code. https://github.com/felixfbecker/vscode-php-debug
Here is what I think I'm missing. I believe I need to launch the website from within VS Code for the debugging to work. I can't figure out how to "launch" the php website from within VS Code. The php-debug extension from VS Code only supports launch. It doesn't support "attach" mode. I suspect this is why when I run the website outside VS Code, the debugger doesn't work. Let me be clear, the debugger is working when I hit F5, it just doesn't ever stop on any breakpoints.
To summarize: How can I launch and debug my php website from within VS Code? I'm looking for a detailed step by step guide.
Thank you
I am the author of vscode-php-debug. You do not need to "launch the website" from inside VS Code. When you start the "Listen for XDebug" configuration from the debug section, VS Code (or rather, my debug adapter) will listen on port 9000 for XDebug. You need to run a web server like Apache, IIS or nginx locally on your PC and configure it to serve PHP files - this has nothing to do with VS Code. Then simply open a web browser and navigate to localhost and XDebug will connect to the debugger, stopping on breakpoints.
The two necessary settings in php.ini are:
xdebug.mode = debug
xdebug.start_with_request = yes
(Do not forget to add the subtitle [XDebug] before the settings.
I have trying to get this done for days...and reading through about 20 tutorials, documents, etc...but still no luck.
Here is the thing. I installed wordpress(just for example, can be any php program) on my VPS, and hoping to debug it from my macbook and my desktop. This is clearly a remote debugging thing. So I here is what I done:
1.Installed right version of xdebug and located its .so file on VPS.
2.Changing php.ini and 20-xdebug.ini file on VPS, my settings currently are:
zend_extension=/usr/lib/php5/20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9200
xdebug.show_local_vars=0
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
xdebug.show_exception_trace=0
xdebug.remote_log=/var/log/xdebug.log
;xdebug.remote_host=202.84.93.66
The last line, which is comment out is my desktop IP address, where I run phpStorm. Based on xdebug's documents, if you set remote_connect_back=1, you won't need this host ip to be specifici.
On phpStorm Side, I "start new project from existing code, and specificy the source root on VPS, map it with one of my local dest. PhpStorm just downloaded all the files and after setting up "Automatic upload", the sync is perfect.
On phpStorm side, I specificy the PHP intercepter as the remote one on my VPS.
On phpStorm side, I changed my debugging port to 9200, as same as the one I using on VPS.
Using the booklet method phpStorm provide, I put them on my firefox bootkmarklet.
Click listen button on phpStorm, set breakpoint, go to firefox open the page, click 'start debuging', refresh.....BUT NOTHING HAPPENS!
I also tried to using the tranditional methods, which set a run configration way as both php-webapplication or php-remote-debug...but still not working.
At php storm, the web debug validation, I could pass all the testing there though....
Can anyone help me with this? I think I must be doing wrong on some very fundation part since I saw all the tutorial are so simple set, but this already took me about 3 days to figure out....
Thanks!
I am trying to install Xdebug on remote server in AWS cloud for profiling purpose. I installed Xdebug i checked using phpinfo() and i kept some setting to enable profiling option on server, it's enabled i verified.
I am saving the output logs of pro filer in a directory on remote server. Now i want to open those files using Kcachedgrind. So i installed Kcachesgrind.
The settings which i used in PHP.ini file are below.
zend_extension="/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.profiler_output_dir = "/opt/lampp/htdocs/profiler/logs"
xdebug.profile_output_name = cachegrind.out.%t-%s
xdebug.remote_enable=On
xdebug.remote_host="ip-10-125-11-57"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.show_local_vars=On
xdebug.collect_return=On
xdebug.collect_params=4
xdebug.profiler_enable=On
xdebug.profiler_enable_trigger=1
In the above settings you can see filed called xdebug.remote_host normally it is localhost but i am in remote server so i kept host name of my server there. I am getting an below error when i tried to open the file using Kcachegrind.
Kcachegrind: Can't connect to X server
You basically have two sane options:
Download the file from the remote server to your local computer and debug them there. If you are annoyed by having to download the file each time, automate the task somehow.
Use a command-line utility for evaluating the file (The xdebug documentation mentions ct_annotate), see here: http://xdebug.org/docs/profiler
I'd strongly suggest option 1.
Be advised, that Kcachegrind is a program with a GUI (Graphical User Interface), meaning: It has windows and buttons and stuff like that. Your remote server usually does not need any GUI software, therefore there is no support for windows and buttons and stuff like that installed (no X server, no KDE, etc...). While TeTeT solution is theoretically possible, please do NOT install X on your remote server and connect via vnc. It is slow, it will use up lots of hard disk space and memory and is a steep learning curve for beginners.
If you really want to debug that on the server, you will need to install X and a desktop for it and connect via vnc.
Maybe it would also work to copy the debug and profile files to a local system and inspect them there.
I have a PHP script that is sending a series of http requests to another php script on another server. I have Xdebug installed on both servers and I'm using NetBeans as my debug client. The problem I am having is that NetBeans can't have 2 debug sessions at the same time and you can't spawn 2 NetBeans processes on the same machine. Am I going to have to run Eclipse and NetBeans at the same time?(YUCK!) Or is there a better way?
I would get another machine, install Netbeans on it, and connect each server to its own debugger. This will help you understand what's happening much better.
Alternate approach: install a virtual machine inside your box, put Netbeans there.
I've using Netbeans to develop on a windows machine, the files I'm editing are on a remote LAMP server. The document root is mounted on my windows machine as a drive letter (Y:). So, netbeans things I'm developing locally, whereas I'm actually developing remotely on a local mount.
My problem starts when I want to use xdebug and netbeans to debug CLI PHP scripts. Debugging browser based stuff is fairly straight forward, but debugging CLI stuff is a little more convoluted and I'm not sure I know how to get it working.
The first problem is that, Netbeans wants to know where the php5 interpreter is, but I can't tell it as it's on the remote server...
Does anyone have any experience with doing this?
Thanks,
Mike
The key Netbeans PHP debugging breakthrough came for me when I added a path mapping to my project (under Project Tab|Right-click Project|Properties|Run Configuration|Advanced Button), so that my project knew how to correlate server source code paths to the local paths (windows drive letter paths).
Example path map:
/home/myusername/sourcedir mapped to x:\sourcedir
I believe I work with a similar configuration to yours (LAMP server, windows machine with the source from the LAMP machine showing up locally under a windows mapped drive). This worked for me.
I had been trying the URLs for my project (http://server/projectroot) as the path mapping. That was not what was needed. The actual path on the server (i.e. my home directory and below) was needed.
Pada meant: xdebug.remote_connect_back, not xdebug.remote_enable. You must have both of them set in order for Xdebug to auto-connect back to Netbeans (or whatever the debugger).
The xdebug.remote_host variable refers to the host that xdebug should connect. You can debug PHP on a remote server using NetBeans, but it would require you to configure xdebug on the remote server such that it would connect to your development PC.
Here's a simple example:
Your development PC, with NetBeans, is on 10.0.0.100,
and your remote PHP webserver is on 10.0.0.1
Set the xdebug.remote_host=10.0.0.100
Now whenever someone (or you) specified the XDEBUG_SESSION_START parameter in the URL on the remote server, xdebug would try to connect to 10.0.0.100.
Xdebug v2.1 has a nice feature: xdebug.remote_enable = 1
Enabling that option would override xdebug.remote_host and then xdebug would connect to the $_SERVER['REMOTE_ADDR'] (which is the IP address that the client is connecting from). This awesome feature would allow you to have multiple debugging on the same server, since you can't manipulate xdebug.remote_host with ini_set()
I don't know about Netbeans, never used it, but in Eclipse PDT where you can also debug using XDebug there is a distinction between "PHP web page" and "PHP script". For "PHP web page" you choose a web server (that you configured earlier) and not a php interpreter (like you have to do with "PHP script").
Perhaps there's the same thing for Netbeans?
xdebug.remote_autostart=1 to automatic remote connection.
in "Xdebug v2.1 has a nice feature:".