Solution to debug PHP code on remote server, using remote IDE - php

There is an IIS server with the XDEBUG extension installed, running a PHP application. I can't change nothing on this server. Sometimes, the dev team here needs to debug it, without changing code. Just put some breakpoints and execute it step by step.
I can do it from my computer using Eclipse and remote debugging. But I would like to create a Debian server, in a VM, to make it easy for anyone with just a browser to place breakpoints and step debug that server, without needing to set up an environment.
I tried many Web-Based IDEs (codiad, cloud9, etc), but they don't offer XDEBUG integration. Is there any web-based IDE that I can install in my own server that offers PHP debugging? Please read this paragraph again and don't answer with spam
Or, is there anyway I could run something in the server side such as Sublime Editor, Notepad ++, or whatever, and see it running in a browser? Maybe a Java applet.
Any bright ideas will be very much appreciated! Thanks!

We just released support for debugging PHP with Xdebug inside Cloud9 IDE.
You can place breakpoints (normal or conditional), step over/in/out, set watch expressions, view the call stack, and inspect variables and values. There's also an REPL mode to evaluate code directly.
It's ready to try, but please make sure the correct dependencies are installed on the workspace by running the following commands:
$ npm install -g debug
$ sudo apt-get install php5-xdebug
Set your breakpoints, then click Run > Run With > PHP (cli) to start the debugger and PHP CLI script.
Would love to hear what your feedback is. Our goal is to add support for debugging PHP web pages and Python soon. The implementation is available open-source on GitHub (https://github.com/c9/c9.ide.run.debug.xdebug)
I also made a quick demo video to show you how it works.

I'm founder of Cloud9, so expect extreme bias.
If you are a decent (or better) coder, I have a solution for you. We already have an implementation of XDebug in javascript here: https://github.com/ajaxorg/lib-phpdebug. It might need a bit of updating as it was written for Node 0.6. It does support the latest xdebug.
In addition, we've just released an SDK that allows you to write plugins for Cloud9. Find more info here: http://cloud9-sdk.readme.io/v0.1/docs/getting-started-with-cloud9-plugins. It allows you to install Cloud9 on your own computer or server and you can develop plugins there. You can also distribute your plugin(s) via c9.io and use the SSH workspace feature to have Cloud9 automatically connect to your VM over SSH.
We just released the (pre-alpha) version of the SDK and are actively supporting the handful of developers on the mailinglist here: https://groups.google.com/forum/#!forum/cloud9-sdk.
Implementing a debugger for Cloud9 is actually fairly straightforward. Someone recently built a C++ debugger, which is still in PR here: https://github.com/c9/c9.ide.run.debug/pull/4. You only need to implement one class, the debugger implementation as documented here: https://docs.c9.io/api/#!/api/debugger.implementation. Since there's already an implementation of the xdebug protocol, tying these things together should only be a few days of work.
I hope this helps.

Related

Optimal setup for OSX PHP development environment: MAMP + Eclipse + Subclipse + XDebug? Other?

I'm in the process of switching over to developing on a Mac (woohoo, new Macbook Air) after years of Windows. My previous PHP development setup was:
WAMP
NotePad++
XDebug
TortoiseSVN and WinMerge (linked to an Unfuddle svn account)
I've just installed MAMP Pro (evaluation copy of Pro), Eclipse for PHP Developers (Version: Helios Service Release 2, Build id: 20110218-0911), and Subclipse. I'm trying to get over the "new to Mac" hump at the same time as switching dev tools. Which is making me question my setup eleventy billion times more than usual. I've read lots of StackOverflow questions and answers, googled the heck out of dev environment tutorials. What I really want to ask is "PLZ tell me what to do to get a good dev setup on my pretty new Mac!" but since that's probably not a very well-formed question, I'll try to narrow it down some. (But if you get bored reading this question, and just want to point me to a good book or tutorial, FEEL FREE!)
MAMP: OK, I think I'm fine on this one, right? It's pretty much the defacto standard, if I don't want to hammer everything together myself from what came pre-installed on my mac. I'm probably fine with dropping $60 to get MAMP Pro, as developers I know have told me the long-term convenience is worth it.
IDE: I used Eclipse for several years... but for Java development in a Windows environment. Part of me is happy to get back to a full IDE after a few years of PHP in Notepad++. But do I want Eclipse for PHP? EclipsePDT? Something else? I picked the version I have based on several StackOverflow answers mentioning that EclipsePDT didn't necessarily play well with Mac.
SVN: I took the StackOverflow hive mind advice to install Sublipse for the eclipse integrated SVN plugin. Yay, it looks like it's working, or at least I can browse my repository.
Debugging: Zend Debug comes with MAMP, right? I've never used it, but I was only semi-happy with XDebug + Notepad++ on my Windows box, as it kept locking up and requiring a Notepad++ restart multiple times a day. Will I love Zend more? Should I stick to XDebug? (Or, wait, does Zend only work with Eclipse PDT?)
Now for the actual setup questions. Given that I've got existing Unfuddle SVN repositories, what's the best way to set up my dev environment? Put the source code into the MAMP htdocs directory, and point the eclipse workspace there? (recommended by many SO answers, IIUC) Vice versa, with code into the default eclipse workspace, and point MAMP to it? A separate Projects/myProject1 directory, pointing both MAMP and Eclipse there? I'm concerned that any of these options will work for the initial setup, but that I'll get deep into the work and discover that my debugger won't work for one configuration or another, or... I dunno, something I haven't thought of yet will cause a problem I could have avoided, if only I'd known.
OSX (also the client version) already includes everything you need to develop with PHP! Oh, and it's all 64 bit :) (on Snow Leopard and Lion)
Apache 2 is included by default and can be enabled from System Preferences -> Sharing (its name is "Web Sharing", or something similar: I'm sorry but I use OSX in another language!).
PHP is installed by default too. You just need to enable it in /etc/apache2/httpd.conf: uncomment this line:
LoadModule php5_module libexec/apache2/libphp5.so
MySQL can be installed from binary packages, downloaded from: http://www.mysql.com/downloads/
The only things you need to change in the php.ini file (/etc/php.ini) are:
pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
You need to manually set the socket location for MySQL or it won't work with PHP.
Also, remember to set a value in date.timezone.
SVN and Git are installed automatically when you install the developer tools for Lion, which can be downloaded freely from http://developer.apple.com/mac (a free registration is required).
If you need Mercurial or if you aren't on Lion (so you don't have XCode 4), download the developer tools, then an application named macports, which provides ports for thousands common UNIX tools: http://www.macports.org/ . Once MacPorts is installed, you can install the required packages with a simple command:
sudo port install subversion
sudo port install git
sudo port install mercurial
I don't use any graphical tool for these SCM, so I can't really suggest you. I prefer the old, plain command line!
Developer Tools (the package with XCode) is required also if you want to use pecl to install custom extensions (the default distribution of PHP Apple ships doesn't contain some extensions like mcrypt, gettext and intl, just to name the three most important).
Speaking about editors... The one I really prefer and love is Coda. It's not free, but it's perfect if you want to develop in PHP: http://panic.com/coda/ .
It's also integrated with SVN (but we use Mercurial so I never used that option!).
For (S)FTP, I recommend you Cyberduck, which is free (open source): http://cyberduck.ch/ . Another really good client should be Transmit, but it's not fee (it's from Panic, the same company that produces Coda): I've never tried it (I'm really happy with Cyberduck!), but I heard thousands of good opinions about it.

Is there a true all-in-one solution for PHP Development?

I'm looking for a "SINGLE INSTALLER" solution for PHP Development.
Is there anything out there which will give me a nice IDE, Web Server, Debugger, Database, etc, on a single install image (*.msi or *.exe)?
This of course would be completely opposite of Eclipse PDT, which requires you to search and locate a bunch of additional components which never quite work together.
I think you should go for a separate install for server (web, database) and one for development (IDE, debug) -> Zend or PHPed ?
I think the question is: Does there need to be a true all-in-one solution? I think not.
I agree it's bothersome to have to put dozens of pieces together, but I find a combination of XAMPP, the IDE of my choice, and a few additional bells and whistles (like Polystyle for source code formatting) totally flexible, and not too much work to install.
I don't know if you'll find all of what you're looking for in one package for Windows, but you can get it narrowed down to about two...
XAMPP for Windows comes with: Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.
Then you just need an editor with a debugger, which there are many choices, mostly non-free, such as NuSphere's PhpEd - or free - such as Eclipse PDT or gVim+XDebug+DBGp client.
True one-in-all - not yet. Maybe someone reading this will upload a version.
My tip would be:
XAMPP and Netbeans (The PHP bundle).
2 clicks to install.
3 clicks if you don't have java installed already.
Netbeans is a nice IDE for PHP, too. I use it all the time and I'm much more satisfied with than with Eclipse PDT. It comes in one neat bundle, that you can just install and use right away.
Just download the PHP bundle here
As for a web server, I can recommend XAMPP or Zend Server. They are both easy to install and do a good job. XAMPP has MySQL on board while Zend Server has some really cool optimization features for great performance.
Should it be a requirement that your development environment is easy to install? You're a developer so, you should be able to install and configure a set of (more powerful) tools that suit your specific needs.
You'll only install your bundled IDE once (every so often) so that feature no longer is of benefit when you're developing your projects. It's more likely to become a hindrance as you struggle to configure your environment.
Take a look at Komodo IDE also.
If you're on windows you can get a WAMP package for web,php,database. For IDE I do like Zend Studio 5.5. Not their latest interation based off of PDT. 5.5 has a nice debugger and a built-in web browser that you can view output. The interface is pretty fast, running your code through the debugger/browser is slower than on a real webserver, but ofcourse you get the nice perks of breaking,inspecting your code. The only drawback is that Zend Studio 5.5 is not supported anymore and the highest PHP version that works with it is 5.2.13.
Currently though I have a Virtualbox Ubuntu Server image that mirrors my production enviroment, except it has Samba installed so I can easily copy files back and forth.

XDebugging PHPUnit testcases in Eclipse PDT

Until now, I was debugging my PHP scripts and testcases using vim and the appropiate script with python backing it. However, me and my colleagues need to move forward and vim/gvim is not an option for them.
So I've tried to integrate debugging PHPUnit in Eclipse on my setup as an external tool, which again, works with vim. However, it simply waits for something when I
Launch the new external tool, then
start debugging as a CLI script
Remote debugging is enabled, the environment variable XDEBUG_CONFIG="idekey=ECLIPSE_DBGP_127.0.0.1" is also set.
Any ideas?
Addendum
Running the testsuite works. Debugging a web page works. Debugging a given test doesn't.
Eclipse waits forever for something at 57% when trying to debug a phpunit test. I'd like to provide more information, but it doesn't tell me more either.
I have wrote an article about how to get it done launching phpunit unit tests from eclise pdt not using the external tools launcher but the phpunit.php script itself, look here:
http://elespaciodejaime.wordpress.com/2010/04/19/pruebas-unitarias-en-joomla-con-phpunit-y-soporte-para-debugging/
the explanation is at the end, by the way, it is in spanish.
You find a tutorial and the code of a simple lightweight way of testing Joomla 1.5 and Joomla 3.x component here on Github. You can see what changed between testing under Joomla 1.5 and in Joomla 3.x. The examples are based on the use of PHPUnit + DBUnit installed with Composer and configured and run in Eclipse Luna for PHP Developer (PDT).
you can launch a debug session by going to the php debug perspective and select from the menu run->debug->debug as php web page or debug php script.
If you use zend studio you can debug as a php unit test.
There is also a firefox extension that helps with debugging with xdebug https://addons.mozilla.org/en-US/firefox/addon/3960
Also make sure go to preferences panel and select php->debug->installed debuggers and click on xdebug then click on configure. There should be an option to allow incoming connections. Select that and you can launch remote debug sessions from firefox.

Is there a interactive debugger for php like ruby's debugger?

I watched the Creating a weblog in 15 minutes with Rails 2 and after 9 minutes in the video he shows ruby's interactive debugger, which allows you to call functions/methods from within a running script.
This goes way beyond breakpoints and looks very useful.
Is there something for PHP that gives similar functionality?
Install xdebug and then use one of the debug clients mentioned here.
Although Milen's answer is the only correct one circa 2009, and Xdebug is still a useful tool, using it requires you to recompile your PHP or to edit your php.ini runtime configuration to load it as a shared object. It also means using a specific client application that supports its network protocol, such as an IDE like PhpStorm.
An alternative is phpdbg, which is an interactive debugger that ships with PHP core versions 5.6 and later and can debug PHP scripts written to conform to PHP 5.4 or later.
Using it is simple:
phpdbg php_script_i_want_to_debug.php
Once in the debugger, type help to access the help menu.
If you don't already have phpdbg on your system, it may be because your PHP was configured without the --enable-phpdbg option. You can either:
Recompile your PHP, being sure to add --enable-phpdbg when you run ./configure (this will simply also build the phpdbg binary), or
download the phpdbg source independently and compile it against your installed PHP (assuming you have the PHP source available). Instructions for doing that, while sparse, are here.

Help setting up php for Eclipse

I'm trying to set up Eclipse for php web development. What I would like to do is preview a php web page from within Eclipse, but I cannot figure out how to do this. Is there an integrated web server of some sort that allows this, or do I have to set up IIS/Apache to do it? If so, do I have to have my php files in the web servers path, or does Eclipse auto deploy the files to the local web server? Any information or links would be very much appreciated.
There is a plugin for Eclipse called PDT which makes PHP development a breeze.
For an overview on how to install it, you can refer to the Eclipse website:
http://wiki.eclipse.org/PDT/Installation#Eclipse_3.4_.2F_Ganymede_.2F_PDT_2.0
To actually view the PHP scripts running, I would imagine that you'd have to have some sort of server already installed and running. You could probably set the workspace location to be in the server path, and then view the files through localhost. But maybe the PDT package takes care of some of that for you.
I will make it Very Easy ;)
(1) Go to Eclipse home: http://www.eclipse.org/downloads/ and download Eclipse Classic (Current May/2013 version is 4.2.2)
(2)
One you have eclipse fired-up in you machine Do followings : Help > Install Software
Than, Click On Add
Finally, Add this link: http://download.eclipse.org/releases/indigo for all the list of Add-Ons
and pick PHP under Web Addon (Should be last in the list) and Install it.
Restart you eclipse + thumbs-up to my Ans. and Start Coding ;)
I setup apache/php/MySQL on my windows PC, so that testing environment is not totally unlike my servers (excepting the OS, but 90% of the time that's okay). I create alias's in the Apache configuration to the Eclipse workspace, and just hop between the browser and eclipse. The URL for testing is something like:
http://localhost/project_name/file.php
While this isn't ideal, it is a fairly consistent/smooth process that doesn't require a great deal of configuration within Eclipse. I keep thinking there should be a better way, but I honestly don't think I'm burning enough time to justify the research. Once the setup is done, I don't really loose more time after that, and I can control which version of PHP I'm running on my system.
I don't tend to like integrated browsers for testing of web applications anyway. Every time I've dealt with one, it was completely different from a "real" browser that I had to completely retest anyway. At least this way, I have my Firefox testing done when I'm through the first pass of the logic.
try easyeclipse, it the easiest Eclipse setup i've found
"EasyEclipse for LAMP:
For PHP, Python, Perl, and Ruby development with a web server and a database"
I would also recommend downloading and installing WAMP server which is a really easy all in one Windows equivalent (windows, Apache, MySQL, PHP) of what you are likely to have with a commercial web host. See http://www.wampserver.com for details and download.
As well as pdt which had already been mentioned other alternatives are phpeclipse and aptana studio which is based on eclipse.
Visit this website https://eclipse.org/pdt/. Go to where it says 'Update existing Eclipse'.
The procedure is this "In Eclipse, click Help -> Install New Software and work with *: http://download.eclipse.org/tools/pdt/updates/3.6"

Categories