Download and Install Magento 2 with PHP Composer

by admin February 14, 2018

Composer allows reasonably arranging package dependencies for the PHP-based software. Thus, one can beneficially use it when working with various PHP applications.

Today, we’ll consider the benefits of utilizing Composer when installing Magento 2.

Why PHP Composer?

Being a comprehensive system, Magento 2 ensures smooth work of ecommerce stores. The rich Magento 2 functionality covers such web store management aspects as catalog navigation, inventory management, performance analysis, etc.

Due to its open PHP code, Magento is among the most demanded ecommerce solutions on the market. More to it, the possibilities of Magneto 2 can be further enhanced by installing extensions from third-party vendors.

By using PHP Composer, Magento 2 users get the following benefits:

  • Flawless system installation. When downloading Magento 2 with Composer, it arranges and manages all the corresponding dependencies. This way, users have no need to track and update packages manually.
  • Module adjustment. When installing third-party modules through Composer, the tool updates and patches these extensions according to the previously established package dependencies as well.
  • Reusable libraries. The installed third-party libraries can be repeatedly used without any obsolescence issues.

Installing Magento 2 via PHP Composer

In order to install Magento 2 with Composer you need to get Composer first. This step is not required if you already have the application in your system.

Install Composer

To install Composer, open the command line and initiate the following commands:

curl -sS | php

mv composer.phar /usr/local/bin/composer

Now, you’ve prepared the installation environment and can perform further operations starting with folder permissions.

Setting up Permissions

Once the required dependencies are obtained by Composer, you should configure permissions for the installation folder. The official User Guide recommends selecting the ‘700’ value for folders, and the ‘600’ value for the files in them:

find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;

You can now proceed to the database creation stage.

Establishing a Database

You can create either a new database or use an existing one that will store your Magento 2 data:

echo “CREATE DATABASE magento2” | mysql -u[mysqluser] -p   

Installing Magento 2

To install the system via Composer, you need public and private keys that can be obtained from your Magento profile.

Having checked the keys, specify the following:

composer create-project  –repository-url= magento/project-community-edition <installation directory name>

Your keys will act as a username and a password respectively in the newly created project.

Now, run Setup Wizard and follow its instructions.

Installing Sample Data

Optionally, you can append sample data to your new project. Access your Magento 2 home directory and specify the following:

php bin/magento sampledata:deploy

php bin/magento setup:upgrade

These parameters will edit the composer.json file and install the required data.

Notice that these parameters will edit the composer.json file and install the required data. After this, the system may ask you to reinitiate the compilation. At this point, indicate the following:

php bin/magento setup:di:compile


Magento 2 and PHP Composer can effectively work together to ensure the efficiency of the dependency management process. With Composer, Magento 2 users ensure smooth software updates and reduce the number of compatibility issues.

Social Shares