How does it work?

The installation of Create Magento App is done through many small steps or tasks and we like to group them by their purpose: Preparation, Installation, Configuration, Execution. Each of these groups works with a specific set of technologies to achieve the desired result.

Overview

We use the listr2 library to help us with task definition and display in the terminal. This library allows us to declare independent tasks and execute them in any order we want, passing down context to later tasks. Context is a way for tasks to share information and is a key aspect of Create Magento App installation process.

During the Preparation tasks, for example, context is populated with various settings, such as available ports, Magento version, cma.js configuration, etc, and the data is then used in later tasks. This approach simplifies the data flow and makes it easy for us to focus on one thing at a time, instead of doing multiple operations within each task.

Preparation

This is the first group of tasks that are executed once you run Create Magento App. Tasks of this group perform various checks to validate that the necessary requirements are met and set up your machine to be ready for installation.

Create Magento App uses Docker, PHPBrew, and Composer under the hood and we have a task that is responsible for validating that all of them are installed on the machine and are ready to run, including their dependencies. Below will be the list of tasks that are responsible for preparation.

Checking cache folder

Create Magento App works with a lot of data and we don't want to run all of the operations each time the project is started, this is why some of the settings are cached for further use. This task is responsible for validating the presence of the cache folder.

Checking requirements

Create Magento App uses Docker, PHPBrew, and Composer under the hood and this task is responsible for validating that all of them are installed on the machine and are ready to run, including their dependencies. In the scope of this task, your OS is also validated as Create Magento App only works on Mac and Linux.

Loading Magento version

In case the machine has a local Magento installation or multiple Magento installations, the user will be prompted to select the Magento versions that they want to use. In case the Magento installation is missing, the default version (2.4.1) will be chosen instead.

Get cached ports

Retrieves cached ports from the cache folder. This is needed to gracefully stop currently running Docker containers.

Stopping Docker services

Stops running Docker containers of Create Magento App. If not containers related to the project are running, the task will be skipped.

Stopping php-fpm

Kills the php-fpm process. Only the local php-fpm process for Create Magento App will be stopped.

Get available ports

Retrieves the list of available ports. Will find free ports in case of the first installation, otherwise will validate the ports that have been retrieved from the cache in one of the previous steps. In case one of the cached ports is no longer available, a new one will be found instead.

Save configuration

Saves the list of available ports to the configuration for further use in the application setup.

Installation

The second group of tasks is where PHP and Magento get installed. PHP extensions are also installed in the scope of this task group.

Install PHP

Installs the PHP binaries according to the version specified in the cma.js, otherwise installs PHP version 7.4.13 by default. During each subsequent run, this task will check for PHP extensions configuration and install any missing extensions, if they are present.

Install Composer, prepare FS, and download images

Installs Composer to allow for Magento to install its dependencies. Prepares File System by creating folders and files necessary for Nginx, PHP, and php-fpm to run. This includes creating SSL certificates and updating the internal configuration file with paths to certain binaries and executables.

These tasks are grouped into one to run them in parallel, heavily decreasing the time needed for initial installation.

Configuring PHP extensions

This task is responsible for configuring the PHP extensions and adding them to the active PHPBrew instance.

Install Prestissimo

Installs Prestissimo, a plugin for Composer to allow it for parallel package installation. This plugin heavily decreases the time needed for initial installation, due to installing Magento's dependencies faster.

Install Magento

This is finally the task where Magento installation takes place! This task creates the project folder, installs Magento, and connects with the ScandiPWA theme created using Create Scandipwa App if present.

Configuration

Tasks in this group are responsible for creating and configuring the infrastructure needed for the application to work. This includes the Magento configuration itself as well as the setup of the Docker infrastructure, and connection establishment to the MySQL container.

Starting Docker services

Starts 4 Docker services that are required for Create Magento App to operate. These services are ElasticSearch, MySQL, Nginx, and Redis. In case of initial installation, an appropriate Docker network will be created as well as Docker volumes to store the data.

Connect to MySQL server

Running MySQL instance is one of the requirements for Magento configuration, and the Create Magento App makes sure that the connection is established. A check is made to see if the MySQL container is running and in case it's not, the retry mechanism is in place. A total of 10 tries will be made with a 5-second interval between each and in most cases, it's enough to establish a connection.

Setup Magento

In this task, the Magento instance is configured for local development. Many sub-tasks will prepare the Magento instance by migrating the database, configuring URLs, creating an admin user, disabling the maintenance mode, and disabling the 2FA.

Execution

Tasks from this list will use the data from all previous tasks to start the application up.

Starting php-fpm

Starts the PHP process manager and the Magento instance.

Open browser

Opens up localhost in the browser. The Magento app will be accessible from there.

Last updated