Thanks to a lead from Aaron Heimlich in the last post on my debugging attempt, I’ve got PHP debugging working on my Mac.
I made a short movie on how the debugger works (seen below) mostly because I wanted to use my fancy (read dorky) new title sequence :-D. First though, this is how you get the debugger setup.
You’ll need to download and install MAMP (an all-in-one Apache / PHP / MySQL application). MAMP stands for Macintosh, Apache, MySQL, and PHP if you didn’t guess. You can use MAMP’s distribution of Apache with the dbg.so without any problems.
After you have MAMP installed, follow the steps in the original post, but do not do sudo make install. Instead of make install, copy the dbg.so file (in the modules directory) into MAMP’s php4 extensions directory: /Applications/MAMP/bin/php4/lib/php/extensions/no-debug-non-zts-20020429 (from what I understand the current debugger does not work with php5). If you want, you can download the ones I compiled here. They are PPC only, and I offer no warrantee of any kind, etc etc.
Once you’ve copied the file, edit MAMPs php.ini file located in: /Applications/MAMP/conf/php4/php.ini. For reference, you’ll want to add the following lines in that file:
...
extension=dbg.so
...
[debugger]
debugger.enabled = true
debugger.profiler_enabled = true
debugger.JIT_host = clienthost
debugger.JIT_port = 7869
After you have the server setup, you’ll need the command line program as well. Again, follow the last post on how that needs to be done. If you have the Apple Developer tools installed, it shouldn’t cause you any troubles.
Once the command line application is ready, create a file called .dbgcli_init in your home directory and add the following lines (obviously using your project’s information where applicable):
set mode on
set mapurlroot http://192.168.1.200/
set mapremoteroot /Users/robrohan/Documents/workspace/MvCphp/
set maplocalroot /Users/robrohan/Documents/workspace/MvCphp/
set port 7869
You should be all set to debug after that. The following movie is an example of how to use the debugger and some basic commands that should get you started.
(One quick note, in the movie I said Apple didn’t include the headers and I meant symbols).
Thanks for the tutorial. Have you tried to get the GUI debugger in xcode working with MAMP/PHP?
Hi jin,
No, I haven’t. Where I am working we have inadvertently standardized on using Eclipse (we have developers on Mac, Linux and windows) so I haven’t tried that.
In fact, I didn’t even know you could hookup random debuggers in xcode – I’ll have to check that out.
Turning PHP error reporting back on in MAMP: http://www.jhuskisson.com/code-tidbits/re-enabling-error-reporting-in-mamp
Thanks for the post.
Couple clarifications:
>”you’ll need the command line program as well”
-What is ‘the’ command line program?
-Is it necessary to Install Apple Dev tools?
>”go into the cli directory”
-Where is the ‘cli directory’? What is the name of the program I need to get if I dont have a clr direcctory?
Thanks…….
Hi tyler,
Check out the first post (the fail one) and I think most of your questions will be answered (See the Command Line section)
http://robrohan.com/2007/05/08/php-debugger-on-mac-dbg-fail
Regarding the Apple Dev tools: Yeah you need gcc (the C, C++ etc compiler) and that is the easiest way to get it.
In reference to the cli directory in that post (I just looked and it’s not that clear if you just jump to that section) the DGB source code has the command line program and the directory that code is in is “cli”
Hi 小罗,
What am I compiling that I need the gcc compiler for? The DGB itself comes in binary right? Maybe this is why I’m having a difficult time, because I dont understand the conceptual process here.
Basically I thought the DGB was a php extension that was run through a command line and/or gui app. ? Whats the compiler for?
Thanks
If you read the original post http://robrohan.com/2007/05/08/php-debugger-on-mac-dbg-fail/ you’ll see why.
You may not have problems with DGB binary (which perhaps is intel only I’d have to relook), but I did. I had to compile the code from source.
If you read that other post as I suggested, you will understand.
Thanks but I read the original post many times and it’s not clear once it jumps to the command line section. I got DBG extension installed but can’t find the ‘cli directory’. Maybe I’m missing some conceptual steps here but the original post does not explain exactly where the cli tool is coming from and what gui you are debugging with, sorry.
If all you need the Apple Dev tools for is to compile this, then there’s probably a smaller gcc compiler available (Apple Dev is about 1GB just to compile this?)
Anyway I read the original post many times and its not very clear once it gets to the command line.
dbg-cli is in the sources, see sourceforge dbg2 project. All the sources are there.
If you’re interested in a debugger with GUI front-end, see this post:
http://support.nusphere.com/viewtopic.php?t=4221