IntelliJ IDEA 2018.2 Help

Installing an AMP Package

AMP packages are operating system-specific. The most common ones are:

  • XAMPP for Windows.

  • The LAMP package compatible with the Linux distribution used.

  • MAMP for macOS.

The installation procedure depends on the operating system used, follow the installation instructions provided.

To install and configure an AMP package

  1. Download and install the desired AMP package.

  2. Use the AMP control pane to start the components.

    If the web server does not start, most likely a port conflict takes place. By default, the Apache HTTP server listens to port 80. This port can be already used by other services, for example, Skype. To solve the issue, update the server configuration file as follows:

    • Locate the line Listen 80 and change it to, e.g., Listen 8080.

    • Locate the line ServerName localhost:80 and change it accordingly, in this example to ServerName localhost:8080.

    Save the configuration file and restart the Web server.

  3. To check your installation, open your browser and type the following URL address: http://localhost:<port number>. The AMP welcome page appears.

To integrate an AMP package with IntelliJ IDEA

  1. Configure a local interpreter as described in Configuring Local PHP Interpreters.

  2. Install and configure a debugging engine as described in Configuring Debugger Options.

  3. Configure integration with MySQL server as described in MySQL.

Tutorial: Integrating XAMPP with IntelliJ IDEA

XAMPP is a cross-platform package consisting of an Apache HTTP server, MySQL database, PHP interpreter, and Perl interpreter. The word "XAMPP" is an acronym, where "X" stands for "cross", meaning "cross-platform", and the other letters stand for the package components.

XAMPP 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. XAMPP is a good alternative to installing and configuring a Web server, a PHP engine, a database server, and a debug engine separately. To start developing, you will only need to download and install XAMPP, and start the components using the XAMPP control panel.

Downloading and installing XAMPP

Download and install XAMPP from the XAMPP Downloads page. Once the XAMPP archive is downloaded, unpack it and run the installer. The XAMPP installation wizard is pretty straightforward, you only need to proceed through the installation steps.

Having installed XAMPP and launched its components, we now need to tell the IDE where these components are stored and how they are configured.

XAMPP Control Panel

After installation, use the XAMPP Control Panel to perform such actions as starting or stopping servers and changing configurations.

Starting and stopping servers

To start a specific server, click the Start button next to it.

ps xampp start servers

By default, none of the servers such as Apache or MySQL are installed as Windows Services. This means that whenever we want to make use of these servers, we have to manually start them through the XAMPP Control Panel. When a server runs as a Windows Service, it with Windows automatically.

To run a specific server as a Windows Service

  1. Open the XAMPP Control Panel as an administrator.

  2. Stop the server you want to install as a Windows Service by clicking the Stop button.

  3. Click X next to the server and confirm the service installation. Once the installation succeeds, a green checkmark will be displayed next to the server, indicating the server is now running as a Windows Service.

    ps xampp installed services

Integrating XAMPP with the IDE

Integrating the PHP executable

Let's start by registering the PHP executable from XAMPP in IntelliJ IDEA. In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Languages & Frameworks | PHP.

ps xampp php settings

With IntelliJ IDEA, we can have several separate PHP interpreters registered in the IDE, depending on the PHP version or PHP configuration needed for the project. All currently registered installations of PHP interpreters are displayed in the CLI Interpreter list:

ps xampp interpreters list

To add the interpreter installed with XAMPP

  1. Click browseButton to the right of the list. The CLI Interpreters dialog opens.

  2. In the left-hand pane, click the icons general add svg button on the toolbar.

  3. In the Name field, type the name to identify the current installation, for example XAMPP PHP 7.2.

  4. In the PHP Executable field, specify the folder where the php (PHP executable) file is stored. Either enter the path manually or click browseButton and locate the file.

  5. IntelliJ IDEA checks whether the specified folder contains a PHP executable file, detects the PHP version, and displays it in the PHP Info read-only field. IntelliJ IDEA also validates that the debugger is configured correctly.

    ps xampp interpreters dialog

We can now save these settings and select the newly added PHP interpreter for our project:

ps xampp interpreter selected

IntelliJ IDEA will now use the PHP installation that was bundled with MAMP.

Integrating the debugger

IntelliJ IDEA offers a powerful debugger in which breakpoints can be set and variables can be inspected at runtime.

Once you have installed and configured the debugger, you can validate your debugging configuration by performing the steps described in Validating the Configuration of a Debugging Engine.

Integrating the Apache server

Interaction between IntelliJ IDEA with Web, FTP, and other servers is handled by the Remote Hosts Access plugin, which is enabled by default. The IDE accesses servers using the connection settings specified in the registered server access configurations.

To create and manage server access configurations

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), click Deployment under Build, Execution, Deployment.

    ps xampp deployment list empty
  2. Click the icons general add svg on the toolbar to add a new server. In the Add Server dialog that opens, specify a name for the XAMPP server and select the deployment type. For the XAMPP Apache server, select the Local or mounted folder type.

    ps xampp add server
  3. After clicking OK, we can specify the path of the Apache's web root (C:\xampp\htdocs) and the URL of the web server, http://localhost. Note that the actual settings depend on how you have configured the XAMPP Apache server through the C:\xampp\apache\conf\httpd.conf configuration file.

    ps xampp server configured

    Don't forget to mark the server as default by clicking , so that IntelliJ IDEA uses it with browser integration instead of the built-in web server.

    By clicking Open, we can open the MAMP htdocs folder in the browser and thus verify that the provided settings are correct.

Integrating the MySQL server

IntelliJ IDEA allows to connect to the XAMPP MySQL database server using the Database Tools and SQL plugin, which is installed and enabled by default. Before you start, make sure that the MySQL server is running on the XAMPP Control Panel.

From the right-hand side of the IDE, open the Database tool window.

ps xampp select db tool

Here, we can create a new connection or Data Source by using the context menu or the toolbar button. We need to specify the JDBC database driver that will be used to connect to our database. For MySQL, we can use the MySQL Connector driver available in the list of drivers. IntelliJ IDEA doesn't ship these drivers but we can download the correct JDBC driver by clicking link.

Next, we need to enter the connection details. Alternatively, we can provide the connection string to the MySQL Database in the Database URL field, for example jdbc:mysql://localhost:3306/ or jdbc:mysql://localhost:3306/foodb to connect to the foodb database.

Note that it is recommended to change the default MySQL username and password after installing XAMPP, which can be done on the http://localhost/security/xamppsecurity.php page.

We can also specify the username and password for MySQL. By default, XAMPP uses root as the user name, and a blank password.

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=utf8&useUnicode=true. It may also be required to select a different JDBC driver from the list, that is, com.mysql.jdbc.NonRegisteringDriver.

Having defined the data source, click the Test Connection button to verify the settings and make sure IntelliJ IDEA can connect to MySQL.

ps xampp data source props

We can now create tables, run queries, update data and so on. See Databases and SQL for more information.

Last modified: 20 November 2018

See Also