I am working on one web application. The project located on my linux box i.e. server.
We are remotely accessing this machine from Windows.
I am using xdebug for debugging along with Eclipse PDT.
xdebug is installed on my server. The below configuration is set in the php.ini file (which is located on the server):
xdebug.remote_enable=1
xdebug.remote_host=10.88.36.1
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_log = /tmp/xdebug.log
After doing the above configuration setting in php.ini for xdebug, it's allowing only one host ( i.e. 10.88.36.1)
I want to allow for multiple hosts. I know in zend debugger there is a configuration parameter option which does this i.e.
zend_debugger.allow_hosts=10.88.36.28, 10.88.36.1
Is there an equivalent option for xdebug so that i can able to allow multiple hosts to have access to server remotely?
This discussion suggests using a 'DBGp proxy'. The linked PDF gives a general idea of what to look for. Further research shows only one implementation: Active State DBGp Proxy which is distributed as part of the Komodo package. Configuration is documented here. A slightly older version is available separately.
I'm not sure if this is a perfect solution for your problem but I found that it will accept multiple hosts in this fashion:
xdebug.remote_host=10.88.36.1
xdebug.remote_host=10.88.36.2
xdebug.remote_host=10.88.36.3
xdebug.remote_host=10.88.36.4
Although multiple connections will not be able to debug at once, if a machine is listed here it should be able to connect. Also correct me if I'm wrong but block definitions do NOT work (ex. 10.88.36.0/24) as far as I can tell.
Source: me mucking around
Related
I can't seem to get my Xdebug to work with PhpStorm.
It works fine for PHPUnit tests, so I'm assuming it's an issue with my local server.
Now for those tests I always have a Configuration for the Test-Class in question (those seem to auto-generate). I do not have one of those prepared for the class I'm currently trying to test (I seem to remember it working at some point and never having an explicit Configuration, but my memory is hazy).
My Debug Configuration:
My CLI-Interpreter (having Xdebug registered):
My xdebug.ini Config:
I'm trying to debug a Magento application running on localhost, port 80.
The issue was that my CLI and Webserver were using different configurations. Thus tests were working fine (using the CLI configuration) but debugging incoming connections did not work (using the Webserver configuration).
The configuration used can be checked via phpinfo() (or php -i for the CLI).
In my case the CLI configuration could be found under /etc/php/{version}/cli and /etc/php/{version}/fpm respectively. Both contained a folder called conf.d in which Symlinks to the desired modules have to be placed (for me they could be found under /etc/php/{version}/mods-available). I added the Symlink for Xdebug in my .../fpm/conf.d configuration and it worked like a charm.
Thanks again for the helpful comments.
I've seen other questions/answer about this topic but none of them seem to have the same issue I have, so here we go:
What I'm trying
I'm using phpStorm 8 to develop PHP websites (CakePHP 2.5.1 in this specific case). I have a copy of the website on my computer, make whatever changes there and upload the new version to the production server via the integrated FTP tool. So far all pretty simple, no issues at all.
Now I would like to start using Xdebug to debug the websites using the production server (PHP 5.3.28), so I'm trying to set up remote debugging with phpStorm and Xdebug.
What I have done so far
I have installed Xdebug 2.1.3 on the production server, and it seems to be working. To test that I've done whats recommended in this other SO question, and all those things work.
This is how the config in php.ini looks like:
zend_extension="/usr/local/src/xdebug-2.1.0/modules/xdebug.so"
xdebug.profiler_enable='0'
xdebug.profiler_enable_trigger='1'
xdebug.profiler_output_dir='/home/username/debug'
xdebug.remote_enable='1'
xdebug.remote_connect_back ='1'
I'm not setting the remote_port variable because I'm fine with the default port (9000). Also, I'm not setting the remote_host IP because I'm using the remote_connect_back option to allow multiple IPs, as explained here.
I've also tried 2 different approaches to set all this up:
I followed this Zero Configuration tutorial, but at step 7 I never get the Incoming Connection dialog.
I also followed this different tutorial but in the Integrating XDebug with PhpStorm step I don't have the choose XDebug from the Debugger drop-down list option on step 3
What I need
If someone could help me figure out what I'm missing or doing wrong that would be great!
I would have added this to the comments, but don't have the needed rep.
Have you set the preferences correctly in your project? Were you able to configure and validate your deployment server (under Deployment)?
After that, set up the server under PHP > Server and validate it as well.
Don't forget to check the firewall on your host.
Make sure that you can get XDebug working without PHPStorm, then circle back around and integrate it.
These are the php.ini settings, other than the driver path, that I am using for my CLI project:
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_autostart = 1
xdebug.remote_host = 192.168.100.1
Most importantly, listen to LazyOne. Specify your remote host. And don't run debuggers on your production gear. Spend some time learning about Virtual Machines. My recommendation is to check out VirtualBox, Vagrant, and SaltStack. Used together, these tools will allow you to debug your code in an environment that is as close to production as possible without adding the burdens and risks involved with your debugging tools.
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 just installed Eclipse PDT 3.0.2 (I don't know what Eclipse base this is, Galileo or Helios), and have been enjoying the step up from NetBeans. In getting more serious about my PHP development (I have recently expanded from only ASP.NET), I decided to move from editing my PHP files directly under my Xampp Apache doc root (htdocs), and have created a workspace under my usual source location, c:\development.
It seems to me, from what I have been able to quickly glean from all the horribly disparate resources on debugging PHP files under PDT, that the files need to be debugged under Apache, and thus copied to htdocs. Is there a local debugging option that doesn't require deployment or a PHP server, and how do I get closer to using this type of debugger?
I know nothing about Eclipse but I have a strong feeling that you simply want to be able to configure more than one site with Apache, so you can work on a private copy of your project while you host a live release in the same computer.
I suggest you have a look at the Name-based Virtual Host Support chapter in the Apache manual. You can create local domain names in your system's hosts file. Additionally, you can use different local IP addresses (127.0.0.1, 127.0.0.2, 127.0.0.3...) or different ports.
You also mention you've been coding ASP.NET in the past. It's worth nothing that PHP runs fine in almost all web servers, including IIS. You don't need to install Apache and I'm pretty sure that Eclipse doesn't care about your server's vendor.
It seems to me […] that the files need to be debugged under Apache, and thus copied to htdocs.
No, you can do what I (and probably thousands of other developers, as the other answers indicate) do:
Leave your development files in your home directory, where they belong, and configure your local Web server so that the DocumentRoot for a name-based virtual host is your development root (or a subdirectory of it).
The minimum Apache configuration would look like so:
<VirtualHost *:80>
ServerName localhost
ServerAlias 127.0.0.1
DocumentRoot C:/development/
<Directory "C:/development">
# helpful if you want to browse your files
Options +Indexes
</Directory>
</VirtualHost>
The line
127.0.0.1 localhost
should be in your hosts file already, so you should not need to make any changes there. (However, if you think you need another hostname alias, just go for it. I have currently defined 3 additional ones for testing purposes.)
The Apache manual and other default Apache resources should still be available then by default (here: http://localhost/manual/ etc.). For example (I am on Debian GNU/Linux here, so I do not know the exact XAMPP paths):
Alias /manual "C:/Program Files/XAMPP/apache/manual/"
<Directory "C:/Program Files/XAMPP/apache/manual/">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
AddDefaultCharset off
</Directory>
(It says so – in Linuxese, of course – in my default /etc/apache2/conf.d/apache2-doc.) See the excellent XAMPP documentation for details.
Is there a local debugging option that doesn't require deployment or a PHP server, and how do I get closer to using this type of debugger?
I do not understand that question. There is no "PHP server". There is Zend Server – do you mean that?
If you want to debug PHP scripts for a Web server like Apache, you need to run PHP on that server. In the case of Apache, either as an Apache module, as a CGI handler, or under FastCGI. You only do not need a server if you are developing CLI-PHP scripts. The XAMPP installer should have set that up for you already.
Assuming from your posting that you want to debug PHP scripts that should run on Apache with the PHP module (run a PHP script with <?php phpinfo(); to be sure; I just do not have active PHP debugging experience with anything else), you can configure PDT so that it uses Remote Debugging with the above local virtual host. For that, you also need a server-side debug module for PHP, for example Xdebug or Zend Debugger (the debug clients for both are included in PDT). I had been using Zend Debugger before, but now I am using Xdebug (with PDT 3.0.0v20110516-… in Eclipse 3.7.1 ["Indigo" SR1, released September 2011]¹) because it is free software, packaged with Debian, and highly configurable and capable even though it is for free as well.
This article helped me in particular: PHP remote debugging with Xdebug and Eclipse PDT.
See the Xdebug documentation for more (e. g., independence of client IP addresses).
However, a wealth of information about PDT and debugging with PDT can be found at the PDT Downloads site.
Bottom line: If you are debugging on localhost, you do not have to deploy your code because you have deployed your code already, just by having it in or below the DocumentRoot. Eclipse PDT does not care where the remote code is located; it only accesses a resource via an HTTP URI. If that starts with http://localhost/, so be it :)
(Copying the resources around carries with it the risk of inconsistencies and accidentally overwriting Apache files, so do not do that.)
¹ There is no PHP package for Eclipse Indigo, but you can start e. g. with Eclipse 3.7.1 Classic and install PDT on top of it using the Update Manager. Just select the "Indigo" (or whatever) repository, then "PHP Development Tools" under "Programming Languages". Dependencies should be resolved automatically. See also PDT/Installation.
I don't remember if Eclipse has a local PHP debugging option or not. But I think Zend Studio (which is based on Eclipse PDT) comes with its own PHP binaries. I've never tried to use them though.
Your best bet is to create a new workspace, which I explained how to do here: publishing php files from eclipse to apache htdocs
If you need to setup vhosts (Virtual Hosts) on your XAMPP installation, this is a great and easy to understand tutorial.
If you want suggestions to alternative IDEs then I would go with Zend Studio ($299) or Rapid PHP 2011. While I've never used Rapid PHP 2011, it does look somewhat promising, has many of the same features as many popular IDEs including debugging. Note that in my opinion, it appears to be not quite as professional as Eclipse/Zend (which, again, is why I always recommend those two above others).
I assumed the question was more about 'can I debug in PDT a CLI script'. If that's the case then, yes, you can.
All you have to do is edit the PHP.INI file that your CLI is using and make sure that XDebug is enabled for the CLI and that xdebug.remote_autostart is set to 1. It's quite possible that the CLI PHP is using a different INI file from Apache, so be sure that you're using the correct one.
Finally, in PDT click 'Debug Project' and debug it as a web script, even if it isn't. The important thing is that you essentially are telling PDT to start listening. Once that's done, you should be able to run the script from the CLI and have PDT kick in at the appropriate time. The xdebug.remote_autostart is key, though.
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:".