Installing and Configuring Mamp With Phpstorm Ide: Prerequisites
Installing and Configuring Mamp With Phpstorm Ide: Prerequisites
Tweet
This tutorial will walk you through choosing and downloading the appropriate edition of MAMP, downloading and installing the package,
starting its components, and integrating them with the PhpStorm IDE.
There is also XAMPP for Mac OS X available, which is similar by features, please refer to Installing and Configuring XAMPP tutorial for more
information on this cross-platform package.
MAMP is Mac OS X package consisting of an Apache HTTP server, MySQL database, PHP interpreter, and some libraries. The word "MAMP" is
an acronym, where "M" stands for "Macintosh", meaning it's designed for Mac OS X, and the other letters stand for the package components.
Mac OS X comes with pre-installed PHP interpreter and Apache server, so it can be configured to work well together following the tutorial
published by php.net. PhpStorm-related configuration is similar to the one described in this tutorial. Installing additional packages and configuring
the system environment on your own can be tricky, so this guide describes how to get everything set up at once easily in a separate environment
with complete MAMP package.
MAMP is a reliable and fast way to set up an environment for PHP programming. It provides all the components required for developing, running,
debugging, and unit testing of PHP applications. MAMP is a good alternative to installing and configuring a Web server, a PHP engine, a
database server, and a debug engine separately. All you need to do to start developing is download MAMP, extract the archive, and start the
components using the MAMP control panel.
Prerequisites
Choosing the right MAMP edition
MAMP
Downloading the MAMP installer
Installing the MAMP package
MAMP Control Panel
Starting and stopping servers
Integrating MAMP with the IDE
Integrating the PHP executable
Integrating the debugger
Integrating the Apache server
Integrating the MySQL server
Prerequisites
Before starting, the following tools should be available on your system:
Either PhpStorm or IntelliJ IDEA Ultimate Edition
When working with IntelliJ IDEA:
The Remote Hosts Access plugin should be enabled (installed and enabled by default with IntelliJ IDEA and PhpStorm)
The PHP plugin should be installed and enabled
MAMP
In this tutorial, we will use the latest MAMP 2.1.4 version.
We will be using the pkg version (in zip archive). There is also source code available in zip archive and svn repository.
Once the download of the package is completed, we can run it.
You can configure MAMP clicking Preferences... button. There are various options available:
PHP version and caching options on PHP tab
Start/Stop Servers configuration on Start/Stop tab
Apache and MySQL ports on Ports tab
Apache document root on Apache tab
Let's start servers by clicking the Start Servers button. Icons on the left will get green and Start Page will be opened (http://localhost:8888/MAMP
/ by default). The default page contains information about your environment and useful links.
With IntelliJ IDEA and PhpStorm, we can have several separate PHP interpreters registered in the IDE, depending on the PHP version and/or
PHP configuration needed for the project. All currently registered installations of PHP interpreters are displayed in the Interpreter drop-down list:
We can add the one we've installed with MAMP by clicking the Browse button ( ). This will bring up the Interpreters dialog box.
1. In the left-hand pane, click the Add (+) button on the toolbar.
2. In the Name text box, type the name to identify the current installation, for example PHP from XAMPP.
3. In the PHP Home text box, specify the folder where the PHP executable file php is stored. We can enter the path manually or use the Br
owse button to find the path on our system.
4. The IDE checks whether the specified folder contains a PHP executable file, detects the PHP version, and displays it in the PHP Info rea
d-only field. Starting with PhpStorm v7.0, the IDE also validates that the debugger is configured correctly.
We can now save these settings and select the newly added PHP interpreter for our project:
Our IntelliJ IDEA or PhpStorm IDE will now make use of the PHP installation that was bundled with MAMP.
Once you have installed and configured the debugger, you can validate your debugging configuration by using the tutorial.
From the toolbar, click the Add button to add a new server. From the Add Server dialog, we can specify a name for our MAMP server and select
the deployment type. For MAMP Apache server, select the Local or mounted folder type.
After clicking OK, we can specify the folder to Apache's web root (/Applications/MAMP/htdocs) and the URL to the web server, http://localhost:88
88. Note that these settings may be different depending on how you have configured the MAMP Apache server in the MAMP configuration or
Apache configuration files.
Using the Open button, we can verify that settings are OK. Once done, we should see the MAMP htdocs folder.
Next, from the right-hand side of our IDE, we can open the database tool window.
Opening the database pane, we can create a new connection or Data Source by using the context menu. We'll have to specify the JDBC
database driver to be used to connect to our database. For MySQL, we can use the MySQL Connector driver available in the list of drivers.
PhpStorm doesn't ship these drivers but a simple click (on Click here) fetches the correct JDBC driver from the Internet.
Next, we'll have to enter our connection details. As the JDBC driver class, select the com.mysql.jdbc.Driver driver. The Database URL should be a
connection string to our MySQL Database, for example jdbc:mysql://localhost:8889/ or jdbc:mysql://localhost:8889/foodb to connect to the foodb d
atabase. We can also specify the username and password for MySQL, root for both username and password by default in MAMP.
When using UTF-8 or unicode characters in the username, password or database name, two additional parameters must be added to the
connection string: characterEncoding and useUnicode. An example connection string would be jdbc:mysql://localhost:8889?characterEncoding=u
tf8&useUnicode=true. It may also be required to select a different JDBC driver from the list, com.mysql.jdbc.NonRegisteringDriver.
Using the Test Connection button, we can verify the settings and make sure PhpStorm can connect to MySQL.
We can now create tables, run queries, update data and so on. See this blog post for more information.
Tweet