(Contributor) Clone the Magento repository
Totally lost? Need a helping hand? Try our installation quick reference (tutorial) or installation roadmap (reference).
Intended audience
The audience for this topic is anyone who contributes to the Magento Open Source codebase. You should be highly technical, understand Composer and Git commands, and be able to upgrade the Magento system software and extensions using those commands. If that isn’t you, go back and choose another starting point.
If you clone the Magento 2 GitHub repository, you cannot use the Magento software in a production environment. You cannot have a live store that accepts orders and so on.
Prerequisites
Before you continue, make sure you’ve done all of the following:
- Set up a server that meets our system requirements
- Created the Magento file system owner
We use Composer to manage Magento components and their dependencies. Using Composer to get the Magento software metapackage provides the following advantages:
- Reuse third-party libraries without bundling them with source code
- Reduce extension conflicts and compatibility issues by using a component-based architecture with robust dependency management
- Adhere to PHP-Framework Interoperability Group (FIG) standards
- Repackage Magento Open Source with other components
- Use the Magento software in a production environment
You must create a Composer project from our metapackage if you want to use the Magento Web Setup Wizard to upgrade the Magento software and third-party extensions.
The Web Setup Wizard is being deprecated in Magento 2.3.6 and will be removed in Magento 2.4.0. After it is removed, you must use the command line to install or upgrade Magento.
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.
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:
1
curl -sS https://getcomposer.org/installer | php
1
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 Magento’s GitHub repository and checking out branches. You can either checkout a release branch or a development branch:
-
Release branches, like
2.x.0
, are more stable. You must use a release branch with the Data Migration Tool. -
Development branches, like
2.x-develop
, contain the latest changes.
You can checkout a specific release branch after cloning the latest code.
Refer to GitHub’s documentation for instructions on cloning a repository.
Creating an authorization file
The Magento 2 GitHub repository requires you to authenticate. The composer install
commands fails if you do not.
Generate Magento and Github keys
To authenticate, you will need to generate Magento authentication keys and a Github personal access token.
Create auth.json
Accessing the Magento 2 GitHub repository requires authentication. The command composer install
fails without it. Requirements to authenticate include:
- Magento authentication keys
- GitHub personal access token
- Composer
auth.json
file
Create Magento authentication keys
Follow this guide to create Magento authentication keys.
Create a GitHub personal access token
The Composer auth file requires the github-oauth
property, but do not create a GitHub OAuth App. Create a personal access token instead.
Follow this guide to create a GitHub personal access token.
When choosing token permissions, select all checkboxes in the repo
scope. Composer auth does not require other permissions.
Create auth.json
file
- Log in to your Magento server as the Magento file system owner.
- Create the
auth.json
file in the user’s home directory. For example, ifmagento_user
is your Unix username, then create/home/magento_user/.composer/auth.json
.
Edit auth.json
file
Replace the <placeholder>
values with your token and keys:
1
2
3
4
5
6
7
8
9
10
11
{
"github-oauth": {
"github.com": "<your GitHub personal access token>"
},
"http-basic": {
"repo.magento.com": {
"username": "<public key>",
"password": "<private key>"
}
}
}
Related topics
After completing the tasks discussed on this page, see Update installation dependencies.