Welcome Guest, Not a member yet? Register   Sign In
I Got a PHP Development Environment/Debugger Working - Here are the Details
#1

[eluser]Vik[/eluser]
Good heavens. It actually took a week - but I finally got a PHP development system/debugger working.

I can't believe it took this long. Professional programmers working on non-web-based applications, usually in C++, but in other languages as well, wouldn't even consider working without an IDE (integrated development environment) that lets you step through your code line by line, examining the contents of variables. They buy one off the shelf, install it, and they're off and running. Given how widespread PHP is, I thought I'd find the same thing for PHP.

But nooooooooo. I found myself compiling source code, installing amp stacks from the command line, modifying PHP.ini files, talking with IDE developers in Europe via IRC chat, and on and on.

So without writing a magazine-length article, I'd like to describe how I got this working.

First of all, you need an amp stack. This cool-sounding name refers to a suite of software that provides you with:

- a working Apache web server that runs on your local computer, the same computer you use to write PHP code.
- MySQL, running inside the server, plus phpMyAdmin to administer it.
- PHP, running inside the server.

Amp stands for Apache/MySQL/PHP.

Why do you need this? You need this because few if any web hosts currently support a server that has a debugger running on it. The reason is that the debugger slows down everything on the server that uses PHP.

So, that means, you need to install all this on your local machine.

Fortunately, it's easy to do. There are a bunch of freeware amp stacks that are excellent. On the Mac, use MAMP. On windows, try XXAMP.

I primarily looked at two IDE's - the open-source PHPEclipse, and the commercial Zend Studio.

PHPEclipse seems pretty good. It's widely used. It's free. There's a book about it that you can buy as a PDF download (http://www.packtpub.com/phpeclipse/book) for $14. If you're running on Windows, I would give it a try.

On a Mac, forget it. There's a little component called a debugger library that you have to install onto PHP on your server to get an IDE to be able to debug. I spent days - seriously, days - trying to compile the debugger library for PHPEclipse, a file called DBG.so. You can get it pre-compiled for Windows, but for some reason on the Mac, you have to compile it. Googling reveals plenty of people trying to get it to work, but I only found one guy (http://robrohan.com/2007/05/08/php-debug...-dbg-fail/) who provided instructions that actually led to a successful compile that my PHP installation could load.

And by the way, unsuccessful compiles from the command line in Unix lead to error messages that you can take days researching. Even the guys who develop PHPEclipse, who I talked with over IRC chat, were baffled when it came to getting dbg.so to be recognized by my PHP installation. And they were really trying hard to get it to work. Frankly, those guys are awesome - they spent over an hour with me on IRC, and did figure out how to get DBG.so to compile. I would totally give PHPEclipse a try if you're on Windows.

Anyway, I finally got dbg.so compiled and loaded in my web server, but then PHPEclipse wasn't loading it. I probably could have gotten it working, given a few more days. The clue I was tracking at that point was to install the amp stack from MacPorts.org, because that's the one that AJT, the PHPEclipse developer who uses a Mac, uses. Maybe that one would have worked with DBG.so. But it just so happens that MacPorts isn't something you just download and run like a normal piece of software, the way MAMP is. Nooooooo. The MacPorts amp stack has to be installed from the Unix command line. And has a habit of generating inscrutable error messages during the install. Figure a day to get a response from MacPorts tech support via their list serve for each error.

Fortunately, I'd been trying to get the Zend Studio IDE working the whole time too, and I was farther along with that one. (Note: figure 1-3 days to get a response from Zend Tech Support.)

Posts on the Zend forum seemed to indicate that you had to get the $300 Zend Platform to get the Zend Debugger. It's not so easy to discover, but Zend Studio also has a free debugger <http://www.zend.com/free_download/studio> that you can download.

They also have an amp stack, called Zend Core, that includes the Zend Debugger. Or so it appears. In fact, Zend Core for Mac doesn't install phpMyAdmin, and doesn't install a working mySQL either. The manual says it does. But it doesn't. I've alerted Zend and they may have that fixed within a few weeks.

So all I had to do, was download Zend Studio Standard ($99 with a free trial), install MAMP, and then download the Zend Debugger, and install that. Once you know how to do it, you can have the whole thing running in 30 minutes. Some good instructions for installing the Zend Debugger are here. (Also, at least on a Mac, you have to comment out all calls in the PHP.ini file to Zend Optimizer, in order to get the Zend Debugger to run.)

It's so great to be able to step through the code, seeing all the brilliant things CI does, without having to guess or figure it out or put in kludgy echo ("") statements to see where the code flow goes.

You enter the URL into Zend Studio, and it accesses the site, running on the amp stack, through your browser. It pulls up your PHP source code in Zend Studio, where you can step through it, set breakpoints, watch the contents of your variables, see the call stack, etc.

Sweet.

(Update - this post follows up on a previous thread, in which I asked for info on "Best Debugger/IDE to Use with CI on Mac?")
#2

[eluser]Michael Wales[/eluser]
There are tons of PHP IDEs.
#3

[eluser]coolfactor[/eluser]
Quote:But nooooooooo. I found myself compiling source code, installing amp stacks from the command line, modifying PHP.ini files, talking with IDE developers in Europe via IRC chat, and on and on.

Scary stuff. I code PHP full-time and never do that stuff. And I use a plain text editor. IDE's have always gotten in the way of my creative debugging skills. Smile

Quote:It’s so great to be able to step through the code, seeing all the brilliant things CI does, without having to guess or figure it out or put in kludgy echo ("") statements to see where the code flow goes.

I do agree with this. Would be nice to eliminate that step from my debugging process.
#4

[eluser]coolfactor[/eluser]
On a Mac, run from the built-in Apache, no need for MAMP, and check out /Applications/Utilities/Console.app. Bring up the /var/log/httpd/error_log file to show you what might be going on with PHP and Apache. Works for me anway.
#5

[eluser]Jon L[/eluser]
The difficulty getting it working, plus supposed security holes opened by using remote debugging, are reasons why I haven't pursued that for my own projects. It would be nice to get debugging functional, but for me, it's not worth the time/effort

I'd maybe use a debugger if I ever get to the point where I have my own company and can easily control the status of live/test servers, development environment, etc, and have an IT guy that I can make do all the dirty work :-D

Again, congrats, hopefully it turns out to be a good investment on your part
#6

[eluser]Vik[/eluser]
Thanks. I find this is a big help to me in tracing program flow, and in seeing what vars are being set correctly and which aren't as I develop.

Hopefully it won't be as hard for other to set up an IDE as it was for me, because I posted the findings of my travails. Smile
#7

[eluser]chobo[/eluser]
I feel your pain... While I haven't had that experience, I have spent days, and at some times weeks on end to figure out stuff (cakephp... linux installs, etc..) I usually get frustrated, curse and move on (then go back and try some more Smile). For debugging I just use echo and print_r statement, I can track down a problem very fast (in seconds), so a debugger is something I can live without; in PHP anyways Smile The odd time some weird things go awry and it takes awhile, but nothing good old echo and print_r can't fix (and sometimes var_dump).
#8

[eluser]Iksander[/eluser]
I don't use an IDE either - been teaching myself ViM and wonder why modal editors aren't used by everyone. Loads up fast and my productivity is incredibly fast too, has some really cool features and alot of very useful addons - including modules for integration with Subversion.

I used to be an Eclipse user - it certainly is a nice editor, but, it takes for ever to load and my productivity with it vs ViM is pitiful.
#9

[eluser]Vik[/eluser]
My original post is out of space for an update, so I'll note here that the full $300 Zend Debugger is needed for remote server debugging - and it turns out that that does include a server that is running on your local development machine. I didn't find out until my trial period was over and it was time to register. For my development purposes, it's worth it - my app has a lot of variables that need watching - way too many to conveniently watch via echo statements.
#10

[eluser]Majd Taby[/eluser]
here's my two cents...first of all for some reason you can download infinitely many free trials of zend studio...using the same account...i did that for about a year. But then i came onto vim..so this part of the post echoes iksander's. Personally the way vim handles movement is unmatched...and it goes really well with my 20" imac so i can have 4 splits open comfortably w/o moving my hand from the keyboard to the mouse once




Theme © iAndrew 2016 - Forum software by © MyBB