MacOS requirements

Apple Silicon is supported as well! To get CMA working on Apple Silicon go to the following section.

1. Install Brew

Brew can be installed from the official website or you can copy-paste this command in your mac terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install dependencies

Run the command below to install the required system dependencies.

Since magento-scripts@1.4.0 CMA will also check installed dependencies before starting the application. If some of them are missing, will provide instructions on how to install them!

brew install zlib \
    bzip2 \
    libiconv \
    libzip \
    libsodium \
    curl \
    libpng \
    gd \
    freetype \
    oniguruma \
    icu4c \
    libxml2 \
    openssl@1.1

You need to install dependencies for both platforms if you are running the M1 system!

3. Install Docker for Mac

Download and install Docker Desktop for Mac following the official installation guide.

Heads up!

If you are working outside of users directory make sure to add your directory to bindable directory list in Docker preferences. (Docker -> Preferences -> Resources -> File Sharing) If you don't do that, Docker will be unable to mount some directories inside containers and you will get startup error.

3.1 Increase available resources for Docker

Increase the amount of allocated memory to at least 4 GB. Go to Docker > Preferences > Resources > Memory > Advanced. There drag memory slider to be at least 4 GB. You can also decrease swap size to its minimum value. Also, you can increase the number of CPUs available for Docker. By default, Docker Desktop is set to use half the number of processors available on the host machine. The more you set, the faster Docker containers will be. Just note that the more CPUs you select, the fewer resources will be left for your system.

4. Install PHPBrew

Since magento-scripts@1.7.0 this part will be done automatically.

PHPBrew is used to compile PHP with required extensions to run Magento 2 on your system.

# Install XCode
xcode-select --install

# Install PHPBrew dependencies
brew install autoconf pkg-config

# Download PHPBrew
curl -L -O https://github.com/phpbrew/phpbrew/releases/latest/download/phpbrew.phar

# Make it executable
chmod +x phpbrew.phar

# Move PHPBrew binary to system folder.
sudo mv phpbrew.phar /usr/local/bin/phpbrew

# Initialize PHPBrew
phpbrew init

5. Prepare the environment

To work with Magento you need access keys to access the Magento repository.

  1. Generate Access Keypair

Now you have a public key and private key values.

To use them you have 2 options:

  1. Use COMPOSER_AUTH environmental variable

    This option is used as a global variable on your machine.

    Replace <public key> and <private key> with your public and private key.

    export COMPOSER_AUTH='{
        "http-basic":{
            "repo.magento.com": {
                "username": "<public key>",
                "password": "<private key>"
            }
        }
    }'

    Add the result to your .bashrc or .zshrc and reload your terminal.

  2. Use auth.json file

    This option is used on a per-project basis, so your credentials will be always correct no matter which project you are working on.

    Create auth.json file in the root of your project and inside put the following content using the same <public key> and <private key> you obtained before:

    {
        "http-basic":{
            "repo.magento.com": {
                "username": "<public key>",
                "password": "<private key>"
            }
        }
    }

6. Start your application

Start command description can be found here. To access Magento CLI, Composer and PHP use cli command.

Last updated