Totally lost? Need a helping hand? Try our installation quick reference (tutorial) or installation roadmap (reference).
Contents
Intended audience
The audience for this topic is anyone who contributes to the Magento codebase. If that isn鈥檛 you, go back and choose another starting point.
Composer and Magento
We now use Composer for dependency management. Composer enables us to manage the Magento components and their dependencies.
Everyone who uses the Magento software must install Composer to update components and Magento. If you install Magento using an archive, you don't need Composer to install Magento, but you do need Composer for updates.
Composer provides you with the following advantages:
- Enables you to reuse third-party libraries without bundling them with source code
- Component-based architecture with robust dependency management
- Manages dependencies to reduce extension conflicts and compatibility issues
- Versioned dependencies
- Semantic versioning
- Supports the PHP Framework Interoperability standard
Install Composer
First, check if Composer is already installed:
In a command prompt, enter any of the following commands:
composer --help
composer list --help
If command help displays, Composer is already installed; in that case, you can skip the next steps and continue with Clone the Magento repository.
If an error displays, use the following steps to install Composer.
To install Composer:
-
Change to or create an empty directory on your Magento server.
-
Enter the following commands:
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
For additional installation options, see the Composer installation documentation.
Clone the Magento repository
This section discusses how to get current code by cloning the Magento GitHub鈥檚 develop branch. You can clone either a release branch or the develop
branch:
- Release branches like
2.0
or.2.0.1
are more stable develop
is more recent
Currently, the develop
branch is the default but you can clone a release branch like 2.0.1
using the optional -b <branch name>
argument.
Creating an authorization file
The Magento 2 GitHub repository requires you to authenticate. The composer install
commands fails if you do not. To authenticate, generate authentication keys, after which you create an auth.json
file in the home directory of the Magento file system owner.
Generate authentication tokens
To get your authentication keys:
-
If you haven鈥檛 done so already, create an account on Magento Connect.
(It鈥檚 the same as an account on
magento.com
.)- Click My Account in the upper right corner of the page.
-
In the New Customer section, click Register.
If you already have an account, make sure you know your user name and password, then continue with the next step.
- At the top of the page, click Connect.
-
In the Developers section, click Secure Keys.
-
You have the following options in the right pane:
- If you already have keys, use the Public key as your user name and the Private key as your password.
-
New key: In the Name field, enter a name to identify the keys and click Generate new.
You can optionally generate additional keys; for example, to provide access to
repo.magento.com
to co-workers, contractors, or integrators. -
Regenerate or rename existing keys: Click Regenerate.
You can regenerate your keys for security reasons; for example, you believe they have been compromised.
- Save an existing key if you changed its name: Click Save.
- Disable keys: Click Disable. You can do this if you want to suspend use of your keys.
- Delete keys: Click Delete.
- Come back to this page anytime to view or change your keys.
Create auth.json
To create auth.json
:
- Log in to your Magento server as, or switch to, the Magento file system owner.
-
Edit or create
auth.json
in the user鈥檚 home directory.The following example shows how to add
repo.magento.com
authentication to an existing file:
For example, if your user name is{ "github-oauth": { "github.com": "<your github oauth id>" }, "http-basic": { "repo.magento.com": { "username": "<public key>", "password": "<private key>" } } }
magento_user
, create or edit/home/magento_user/.composer/auth.json
How to clone the Magento 2 GitHub repository
You can clone the Magento 2 GitHub repository using either SSH or HTTPS protocols:
- Use SSH for better security (no user name and password are exchanged). This requires you to share a public key with GitHub.
- Use HTTPS if you don鈥檛 share an SSH key with GitHub (your user name and password are encrypted before being sent to GitHub).
See one of the following section:
Clone with SSH
To clone the Magento GitHub repository using the SSH protocol:
-
Copy to the clipboard the Magento GitHub repository SSH clone URL.
a. In a web browser, go to the Magento GitHub repository.
b. On the right side of the page, under the clone URL field, click SSH.
c. Click the Copy to clipboard button.
The following figure shows an example.
-
Change to your web server鈥檚 docroot directory. Typically, for Ubuntu, it鈥檚
/var/www
and for CentOS it鈥檚/var/www/html
.Need help locating the docroot? Click here.
-
Enter
git clone
and paste the value you obtained from step 1.An example follows:
git clone [-b <branch-name>] git@github.com:magento/magento2.git
-
Wait for the repository to clone on your server.
If the following error displays, make sure you shared your SSH key with GitHub:
Cloning into 'magento2'... Permission denied (publickey). fatal: The remote end hung up unexpectedly
-
Continue with Update installation dependencies.
Clone with HTTPS
To clone the Magento GitHub repository using the HTTPS protocol:
-
Copy to the clipboard the Magento GitHub repository HTTPS clone URL.
a. In a web browser, go to the Magento GitHub repository.
b. On the right side of the page, under the clone URL field, click HTTPS.
c. Click the Copy to clipboard button.
The following figure shows an example.
-
Change to your web server鈥檚 docroot directory.
Typically, for Ubuntu, it鈥檚
/var/www
and for CentOS it鈥檚/var/www/html
. -
Enter
git clone
and paste the value you obtained from step 1.An example follows
git clone [-b <branch-name>] https://github.com/magento/magento2.git
Use
-b 2.0
to clone the 2.0 release branch; omit it to clone thedevelop
branch, which is the default. -
Wait for the repository to clone on your server.
Next step
After completing the tasks discussed on this page, see Update installation dependencies.
Find us on