Download Magento 2 source code for development

2
384
Download Magento 2 source code for development
Download Magento 2 source code for development

In this tutorial, I will show you how to download Magento 2 source code for development. It can be done either via Magento download page or via PHP Composer.

Download Magento 2 source code

As I note above, we can download Magento 2 source code via two ways:

  1. Using Magento download page.
  2. Using Composer

Let’s walkthrough each of them.

1. Using Magento download page

To do this, you first need to visit the page at https://magento.com/tech-resources/download

Magento Download Page
Magento Download Page

There are two main sections:

  • Full Release (ZIP with no Sample Data)
  • Full Release (with Sample Data)

The latter one is larger in size because it contains several modules bundled with Sample Data in case you want to have a real-world-like store setup on your local development environment.

However, before you can download the source code, you need to have an account, so by clicking the Download button, it will redirect you to the authentication page, where you can either login if already having an account or creating a new account. Afterward, you can get the source code.

2. Using Composer

If you want to prepare a development environment with Magento, then using Composer is the better option since it will help update all PHP packages and Magento if necessary.

First, you will need to have an account on Magento Marketplace, which can be done by visiting repo.magento.com and create a new account if you don’t have one.

Next, you need to create an Access Key, visit this link https://marketplace.magento.com/customer/accessKeys/ to create one, just name anything for your keys.

Now, open your favorite terminal, I used iTerm on Mac, and use composer to create new Magento project.

$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento-dev

It will create a new Magento project named magento-dev based on the open-source version of Magento. If you want to access to the enterprise version, change the base project name from magento/project-community-edition to magento-enterprise-edition.

As the first time downloading Magento project from its repository host, Composer will ask to authenticate, you will need to provide the Access Key values created from previous step for this:

Username: PUBLIC
Password: PRIVATE

Would you like to save authentication into Composer config file (auth.json)? [Yn]

For username, use the Public value, and use Private value of the Access Key for password. For convenience of future use, you can answer Y to save the credentials to avoid input these key values.

And that’s the final step. Composer will automatically pull the source code to your environment along with all necessary packages to run projects.

Conclusion

Comparing to other PHP project, it is a bit more complicated just to download Magento 2 source code for development. However, you will get used to it gradually.

For next steps, you might want to setup Magent development environment.