Install Magento 2 using Composer
It’s actual that Magento and a few different engineers have composed articles specifying what I’m going to experience, yet I chose to compose this for the total amateur with more profound clarification of what is happening all through the means – especially the part of Composer.
Step 1: Server Environment
Magento 2 has new least necessities of your LAMP stack. I’m not going to show them here on the off chance that they change so please check the Magento 2 documentation for those essentials.
Step 2: Clone Magento 2
To clone Magento CE 2 into your current directory run the Git following command:
git clone https://github.com/magento/magento2.git
It will clone the repo into a magento2 subdirectory, and this should take about 2-3 minutes depending on your broadband speed. Once it’s done run the following command to move into the Magento 2 root directory and checkout the master branch.
cd magento2
git checkout master
In order to work with Composer a project must have a composer.json file within its root directory. If you take a look at the file you’ll see a huge list of Magento 2 package dependencies. I’ve picked out first three below:
– require: a list of packages (and versions) required by Magento 2. Magento 2 will not install if any of those package dependencies are not met.
– require-dev: a list of packages required by Magento 2 for development (includes running units tests, hence why PHPUnit is in there)
– replace: shows a list of packages that are replaced by Magento 2, which is mostly made up of the main modules that make up the Magento 2 framework – this allows developers to fork specific packages with improved or customised code
To run Composer for the first time and install your packages simply run:
composer install
When upgrades become available you can install future updates by using:
composer update
The beauty is that upgrades will only run if Composer identifies a package’s dependencies can be met meaning the stack should always run smoothly.
Vagrant users should not find this a problem, however you may encounter missing PHP extensions when you install Composer, such as:
- The requested PHP extension ext-mcrypt * is missing from your system.
- The requested PHP extension ext-intl * is missing from your system.
For MAMP users, you can get around this by creating a symlink of your system’s PHP version to MAMPs. Firstly find out your PHP location:
which php // returns for example: /usr/bin/php
And then create the symlink:
sudo mv /usr/bin/php /usr/bin/php.bak
sudo ln -s /Applications/MAMP/bin/php/php5.6.10/bin/php /usr/bin/php
When Composer has finished its install you’ll be ready to install Magento. You can do this via command line, with Composer or through the installer interface.
Step 3: Install Magento 2
The installer interface is better looking than before and it checks your server ‘readiness’ before allowing you to proceed with the install.
Follow the process and once fully installed you’re ready to go.
That’s it, we hope this Magento post helped you to Install Magento 2 using Composer.
Bookmark it for your future reference. Do comment below if you have any other questions or doubts.
P.S. Do share this post with your team.
Review other articles maybe it'll help you too.