This tutorial shows you how to set up PHP on the MAMP (Macintosh, Apache, MySQL, PHP) package, which includes the Apache web server, the MySQL database server, and the PHP engine. MAMP is intended as a PHP development environment for the Mac, which can work seamlessly with the NetBeans IDE.
Xdebug is an extension for PHP that aids in providing information valuable for debugging PHP scripts. The NetBeans debugger works on top of the Xdebug extension, providing an effective debugging tool in your development environment.
To complete this tutorial, you need the following software and resources.
|Software or Resource||Version Required|
|NetBeans IDE||PHP download bundle|
|Java Development Kit (JDK)||6 or 7|
Note: The MAMP package includes the Apache web server, PHP engine, and MySQL database. Mac OS X 10.5 and later include the MySQL database and Apache server with PHP support. While it certainly is possible to configure the built-in database and server with the IDE, MAMP's all-in-one bundle provides a convenient and easily configurable solution.
.dmgfile. When the installer displays, drag MAMP into your
MAMP.app. The MAMP Control Panel opens.
MAMP/README.rtf, which enables you to start and stop servers.
MAMP's MySQL database is located by default at
The default username and password are both
root, which you can verify by
viewing the details in MAMP's welcome page which opens in a browser when you run MAMP.
The IDE interfaces with databases from the Services window (⌘-5). You can register the MAMP's MySQL database by doing the following:
binfolder. You can find scripts for starting and stopping servers there. For the path to the Admin tool, you have a choice; you can link to
MAMP.appso that you can use the IDE to open MAMP's control panel. To do so, enter
/Applications/MAMP/MAMP.app. However, an alternative option would be to use the MySQL Workbench, which provides an intuitive GUI interface for performing administrative operations (i.e., configuring and monitoring the MySQL server, managing users and connections, performing backups, etc.). To use MySQL Workbench, first download and install it, then enter the following settings into the dialog:
/Applications/MySQL Tools/MySQLWorkbench.app(default installation for MySQL Workbench)
When you create a PHP project in the IDE using MAMP's resources, you should specify that the
IDE copy your sources to Apache's
htdocs folder. That way, when you save your
files after making changes, your sources are automatically updated in the deployed version.
For example, when creating a new PHP project use the New Project Wizard (click the New Project
icon in the IDE's toolbar ( ). In the third step of the wizard, Run Configuration, select the
Copy files from Sources Folder to another location option and type in the path to the
The IDE remembers this location for future projects. For further instructions on creating PHP projects in NetBeans IDE, see Setting Up a PHP Project.
MAMP contains a pre-compiled xdebug.so file. To use this file, enable it in MAMP's php.ini. Xdebug does not work together with Zend Optimizer, so you also have to disable Zend Optimizer in php.ini.
To enable Xdebug with MAMP:
php.inifile in an editor. This file is located in:
;[Zend] ;zend_optimizer.optimization_level=15 ;zend_extension_manager.optimizer=/Applications/MAMP/bin/php5/zend/lib/Optimizer-3.3.3 ;zend_optimizer.version=3.3.3 ;zend_extension=/Applications/MAMP/bin/php5/zend/lib/ZendExtensionManager.so
xxxxxxxxwith the actual number). Add this section to the end of php.ini if it is not there.
[xdebug] xdebug.default_enable=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.remote_autostart=1 zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-xxxxxxxx/xdebug.so"For an explanation of these properties, see Related Settings in the Xdebug Remote Debugging documentation.
To debug a PHP project in the IDE, right-click the project in the Projects window and choose Debug. Alternately, if the project is highlighted in the Projects window, you can click the Debug Project icon ( ) in the main toolbar.
You can set the debugger to suspend on the first line of code by enabling this option in the PHP Options window.
When a debugger session is active, the debugger toolbar displays above the editor.
You can also verify that a PHP debugging session is active by opening the Sessions window. Choose Window > Debugging > Sessions from the main menu.
For more information about PHP technology on netbeans.org, see the following resources:
To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE PHP development features, join the firstname.lastname@example.org mailing list.