Recently I have switched from Linux to OS X. In order to continue my job effectively I had to set up a proper development environment. For programming tasks I prefer the NetBeans IDE, which is available for OS X. I have not yet decided about the server side, so currently I’m testing two alternatives. Those are MAMP and the Acquia Drupal Stack which is a great help for Drupal development. I picked Acquia Drupal Stack because most of my tasks are Drupal related and this tool can save me a lot of time. You can watch Gabor Hojtsy’s presentation on Acquia Drupal Stack at DrupalCamp Hungary: here.
Download and install as usual:
- NetBeans: http://netbeans.org/downloads/indexC.html
- MAMP: http://www.mamp.info/en/downloads/index.html
- Acquia Drupal Stack: http://acquia.com/downloads/mac-installer
As a last step you need to install Xdebug.
Enabling Xdebug in MAMP
Fortunately MAMP contains a pre-compiled xdebug.so file, so you only need to enable it in php.ini. At the same time make sure that Zend optimizer is disabled because it does not work together with Xdebug. Edit php.ini using your favorite text editor:
1
|
|
Change the end of the file to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Restart MAMP and check phpinfo()’s output. If you see the following lines then you’ve successfully enabled Xdebug.
Enabling Xdebug in Acquia Drupal Stack
Acquia Drupal Stack doesn’t contain a pre-compiled xdebug.so file, so you have two choices. Either you compile it from source or use MAMP’s pre-compiled xdebug.so file. I chose the latter one. (Note: MAMP ships with php 5.2.11, whilst Acquia Drupal Stack uses version 5.2.9.)
Copy xdebug.so from MAMP to Acquia Drupal Stack:
1 2 |
|
Open php.ini using your favorite text editor:
1
|
|
Add the following lines to the end:
1 2 3 4 5 6 7 8 9 10 11 |
|
In this example Xdebug is using port 9080, which is needed to make sure that MAMP and Acquia Drupal Stack don’t use the same port. If you are not going to use them simultaneously then port 9000 is also fine here.
You can use phpinfo() from Acquia Drupal Stack’s settings:
If you see the following then you’ve successfully enabled Xdebug:
Real time debugging with NetBeans
Below you can see the settings for PHP debugging in MAMP environment:
If you use Acquia Drupal Stack, change PHP 5 Interpreter and Debugger Port settings respectively.
1 2 |
|
Web browser settings should look like this way:
Now you only need to set a break point and start debugging.
I would like to thank itarato and zserno for their help in writing this article. This article was translated to English by zserno. For the original hungarian article click here.
References: