Skip to end of metadata
Go to start of metadata


One of the great things that happened in PHP world was the introduction of Composer, a dependency manager for PHP which allows us to specify dependencies for our project and have Composer install and update them for us. PhpStorm has full support for this great tool in the UI and in PhpStorm's command line tool.
In this tutorial, we'll cover the following tooling support:

Let's create a project using the Symfony framework and install dependencies using Composer support in PhpStorm.


If you experience problems (e.g. Can't open SSL connection) when installing packages with Composer - please check that you have openssl php extension enabled - it's required by GitHub to access the repository. More information on how to enable openssl can be found in the PHP manual.

Creating a new project with Composer

When creating a new project in PhpStorm using the File | New project... menu, we can choose from a list of project types. PhpStorm 6 introduced a new project type: Composer project.

When using this project type, PhpStorm will present us with a dialog which allows us to do two things. We can specify the path to composer.phar (or have PhpStorm download it from and we can start adding dependencies through Composer. Using the package filter we can search through packages listed at the Packagist.

Let's install the symfony/symfony package, the official package for the Symfony framework. By default the latest version will be installed, however we can select the version to install from this dialog as well. After clicking OK, PhpStorm will install the selected package into a new project.

Once finished, we have a blank Symfony project which we can start developing in.

Init Composer

In an empty project (or an existing project in which Composer was not initialized), we can right-click the project and use the Composer | Init Composer... context menu to enable Composer support for our project. If you don't have composer.phar anywhere on your system, the Click here to download from helper will download the latest composer.phar from the official website.

This will generate a default composer.json file in our project in which we can describe our project and its dependencies.

Add dependencies

Why type raw JSON in the composer.json file to add dependencies? Not to mention that Composer should be invoked to install dependencies described. PhpStorm comes with a new context menu which is displayed when right-clicking our project: Composer | Add dependency...
Imagine we would like to create spreadsheet documents in our application. We can add a dependency to the phpexcel/phpexcel package with the click of the Install button.

The IDE will add the dependency to composer.json and satisfy any other required dependency automatically for us.

Command line tool support

When full control is needed, we can always use the command line tool in PhpStorm to invoke Composer.

Enabling the Composer command line tool

Before we can use the Composer command line tool, we have to enable it. We can do this globally (for all projects) or on a per-project basis.

  1. From the Project Settings | Command Line Tool Support, add a new tool using the + icon on the toolbar
  2. Select Composer as the tool and specify project as the visibility. Note that other command line tools are supported too.
  3. Specify the path to composer.phar. If Composer is already being used in the project, PhpStorm should automatically fill out this path.
  4. Click OK and note that Composer has been added with an alias "c".
  5. Close the settings.

Using the Composer command line tool

We can bring up the command line tool using the Tools | Run Command... menu or with Ctrl+Shift+X (Cmd+Shift+X on Mac).

PhpStorm comes with full Composer framework support in the command line tool. When we start typing "c" (the alias created in the settings), PhpStorm will come with a list of suggestions and autocompletion support. 

  • No labels