phpstorm installingandconfiguringmampwithphpstormide

Upload: mashe1985

Post on 10-Mar-2016

307 views

Category:

Documents


0 download

DESCRIPTION

Installing and Configuring MAMP with PhpStorm IDE

TRANSCRIPT

  • 1. 2.

    Installing and Configuring MAMP with PhpStorm IDE

    MAMP is Mac OS X package consisting of an Apache HTTP server, MySQL database, PHP interpreter, and some libraries. The word "MAMP" isan 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. PhpStorm-related configuration is similar to the one described in this tutorial. Installing additional packages and configuringpublished by php.net

    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 environmentwith 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, adatabase server, and a debug engine separately. All you need to do to start developing is download MAMP, extract the archive, and start thecomponents using the MAMP control panel.

    PrerequisitesChoosing the right MAMP editionMAMP

    Downloading the MAMP installerInstalling the MAMP package

    MAMP Control PanelStarting and stopping servers

    Integrating MAMP with the IDEIntegrating the PHP executableIntegrating the debuggerIntegrating the Apache serverIntegrating the MySQL server

    PrerequisitesBefore starting, the following tools should be available on your system:

    Either or PhpStorm IntelliJ IDEA Ultimate EditionWhen working with IntelliJ IDEA:

    The (installed and enabled by default with IntelliJ IDEA and PhpStorm)Remote Hosts Access plugin should be enabledThe PHP plugin should be installed and enabled

    Choosing the right MAMP editionFrom the , we can download and install the MAMP edition which matches the Mac OS X version. The following versions areMAMP web siteavailable:

    MAMP & MAMP PRO 2.* (Latest version is 2.1.4) is suitable for Mac OS X 10.6.6+ (including Mac OS X 10.8).MAMP & MAMP PRO 1.* (Latest version is 1.9.6.1) is suitable for Mac OS X 10.4+.

    It's also possible to download additional PHP versions for MAMP PRO 2.1.4.

    MAMP is free software distributed under GNU license. MAMP PRO is a paid version which includes additional features. MAMP can be usedstand-alone without MAMP PRO.

    MAMPIn this tutorial, we will use the latest version.MAMP 2.1.4

    Downloading the MAMP installerFrom the , we can find a list of components included in the package. Download link for the last stable version is on top ofMAMP downloads pagethe page.

    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 for moreInstalling and Configuring XAMPP tutorialinformation on this cross-platform package.

  • We will be using the version (in archive). There is also source code available in archive and repository.pkg zip zip svnOnce the download of the package is completed, we can run it.

    Installing the MAMP packageOnce the MAMP archive is downloaded, unpack it and run the installer ( in our case).MAMP_2.1.4.pkgThe MAMP installation wizard is pretty straightforward. Using the button, we can navigate through all steps in the installation.Continue

  • Click the button to complete installation.Close

  • MAMP Control PanelAfter installation, we can use the MAMP Control Panel to perform several actions such as starting / stopping servers and changing configurations.MAMP Control Panel Application can be found in folder.Applications/MAMP

    Starting and stopping serversTo start Apache and MySQL servers, click the button. To stop running servers, we can use the button. Start Servers Stop Servers

    You can configure MAMP clicking button. There are various options available:Preferences...

    PHP version and caching options on PHP tabStart/Stop Servers configuration on Start/Stop tabApache and MySQL ports on Ports tabApache document root on Apache tab

  • Let's start servers by clicking the button. Icons on the left will get green and will be opened (Start Servers Start Page http://localhost:8888/MAMP by default). The default page contains information about your environment and useful links./

  • Integrating MAMP with the IDENow that we have installed MAMP and launched its components, we need to tell our IDE where these components are stored and how they areconfigured.

    Integrating the PHP executableLet's start by registering the PHP executable from MAMP in PhpStorm. When in a PHP project, we can do this using the menu File | Settings (C

    , navigating to the .md+Shift+S) Project Settings | PHP

  • 1. 2. 3.

    4.

    With IntelliJ IDEA and PhpStorm, we can have several separate PHP interpreters registered in the IDE, depending on the PHP version and/orPHP configuration needed for the project. All currently registered installations of PHP interpreters are displayed in the drop-down list:Interpreter

    We can add the one we've installed with MAMP by clicking the Browse button ( ). This will bring up the dialog box. InterpretersIn the left-hand pane, click the (+) button on the toolbar.AddIn the text box, type the name to identify the current installation, for example .Name PHP from XAMPPIn the text box, specify the folder where the PHP executable file is stored. We can enter the path manually or use the PHP Home php Br

    button to find the path on our system.owseThe IDE checks whether the specified folder contains a PHP executable file, detects the PHP version, and displays it in the reaPHP Infod-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.

    Integrating the debuggerPhpStorm offers a powerful debugger in which breakpoints can be set and variables can be inspected at runtime. For more information on usingPhpStorm's debugger, have a look at any of the following articles:

    Zero-configuration Web Application Debugging with Xdebug and PhpStormXdebug Installation GuideZend Debugger Installation Guide

    Once you have installed and configured the debugger, you can validate your debugging configuration by using the . tutorial

    Please note that if you are using latest MAMP PRO, , and files should be edited through the Templatehttpd.conf php.ini my.cnfEditor provided by MAMP PRO. Go to to edit template files. When MAMP PRO starts the Apache andFile->Edit TemplateMySQL server it uses these templates to create and files, erasing the previous ones.httpd.conf php.ini

  • Integrating the Apache serverInteraction between IntelliJ IDEA or PhpStorm with Web, FTP, and other servers is supported through the , which isRemote Hosts Access pluginenabled by default for IntelliJ IDEA and PhpStorm. The IDE accesses servers using connection settings specified in the registered server accessconfigurations. These configurations are created and managed in the page of the dialog box.Project Settings | Deployment SettingsChoose on the main menu again to open the . Click under the node to go to the File | Settings Settings Deployment Project Settings Deploym

    page.ent

    From the toolbar, click the button to add a new server. From the dialog, we can specify a name for our MAMP server and selectAdd Add Serverthe deployment type. For MAMP Apache server, select the type.Local or mounted folder

    After clicking , we can specify the folder to Apache's web root ( ) and the URL to the web server, OK /Applications/MAMP/htdocs http://localhost:88. Note that these settings may be different depending on how you have configured the MAMP Apache server in the MAMP configuration or88

    Apache configuration files.

  • Using the button, we can verify that settings are OK. Once done, we should see the MAMP htdocs folder.Open

    Integrating the MySQL serverIntelliJ IDEA and PhpStorm allow us to connect to the MAMP MySQL database server using the Database plugin (installed and enabled bydefault). First of all, make sure the MySQL server is running from the MAMP Control Panel. When using MAMP PRO, also make sure that the"Allow local access only" setting is disabled from the MAMP PRO Control Panel.

    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 by using the context menu. We'll have to specify the JDBCData Sourcedatabase driver to be used to connect to our database. For MySQL, we can use the driver available in the list of drivers.MySQL ConnectorPhpStorm doesn't ship these drivers but a simple click (on ) fetches the correct JDBC driver from the Internet.Click hereNext, we'll have to enter our connection details. As the JDBC driver class, select the driver. The Database URL should be acom.mysql.jdbc.Driverconnection string to our MySQL Database, for example or to connect to the djdbc:mysql://localhost:8889/ jdbc:mysql://localhost:8889/foodb foodbatabase. We can also specify the username and password for MySQL, for both username and password by default in MAMP.root

    When using UTF-8 or unicode characters in the username, password or database name, two additional parameters must be added to theconnection string: characterEncoding and useUnicode. An example connection string would be jdbc:mysql://localhost:8889?characterEncoding=u

    . It may also be required to select a different JDBC driver from the list, .tf8&useUnicode=true com.mysql.jdbc.NonRegisteringDriver

  • Using the button, we can verify the settings and make sure PhpStorm can connect to MySQL.Test Connection

  • We can now create tables, run queries, update data and so on. See for more information.this blog post

    Tweet

    Installing and Configuring MAMP with PhpStorm IDE