Create Magento App
Create ScandiPWA AppScandiPWA DocsGitHub
v2
v2
  • Create Magento App
  • Getting started
    • Getting Started
    • Prerequisites
      • Linux requirements
      • MacOS requirements
        • Apple Silicon
      • Windows requirements
    • Available commands
      • Start the application
      • Stop the application
      • Check application status
      • Enter application CLI
      • Explore application logs
      • Execute commands in Docker containers
      • Link a theme
      • Import database dump
      • ⚠️ Uninstall a project
    • Folder structure
    • Updating to New Releases
      • Testing Alpha Releases
    • Configuration File
      • System Configuration File
    • Supported Magento versions
    • How does it work?
    • Limitations
    • What Is New in Version 2
  • Usage guide
    • Using console commands
    • Accessing Docker containers
    • Linking a Scandi Theme
    • Enabling XDebug
    • Enabling SSL
    • Configuring PHP
    • Configuring Multi-Store
    • Configuring NewRelic
    • Access on the local network
    • Using custom domain
    • Using Enterprise Edition
    • Using OpenSearch
    • Importing database
      • Importing remote database
    • Converting legacy Docker setup to CMA
    • Improve Performance
  • Container images
    • PHP Images
      • PHP 8.3
        • PHP 8.3 with Magento 2.4 extensions
        • PHP 8.3 with XDebug
          • PHP 8.3 with XDebug with Magento 2.4 extensions
      • PHP 8.2
        • PHP 8.2 with Magento 2.4 extensions
        • PHP 8.2 with XDebug
          • PHP 8.2 with XDebug with Magento 2.4 extensions
      • PHP 8.1
        • PHP 8.1 with Magento 2.4 extensions
        • PHP 8.1 with XDebug
          • PHP 8.1 with XDebug with Magento 2.4 extensions
      • PHP 7.4
        • PHP 7.4 with Magento 2.4 extensions
        • PHP 7.4 with XDebug
          • PHP 7.4 with XDebug with Magento 2.4 extensions
      • PHP 7.3
        • PHP 7.3 with Magento 2.4 extensions
        • PHP 7.3 with Magento 2.3 extensions
        • PHP 7.3 with XDebug
          • PHP 7.3 with XDebug with Magento 2.4 extensions
          • PHP 7.3 with XDebug with Magento 2.3 extensions
      • PHP 7.2
        • PHP 7.2 with Magento 2.3 extensions
        • PHP 7.2 with XDebug
          • PHP 7.2 with XDebug with Magento 2.3 extensions
    • ElasticSearch Images
      • ElasticSearch 6.8
  • Scripts Extensions
    • PHP Extensions
      • PHP Extensions Package
      • (deprecated) ionCube Extension
  • Troubleshooting
    • Common Issues
    • CMA Debugging
    • Uninstall CMA
Powered by GitBook
On this page
  • Changing the PHP version
  • Installing PHP extensions

Was this helpful?

  1. Usage guide

Configuring PHP

PHP configuration is stored within the cma.js file:

module.exports = {
    magento: {
        first_name: 'Scandiweb',
        last_name: 'Developer',
        email: 'developer@scandipwa.com',
        user: 'admin',
        password: 'scandipwa123',
        adminuri: 'admin',
        mode: 'developer',
    },
    configuration: {
        php: {
            // PHP configuration goes here
        }
    }
};

Changing the PHP version

PHP to Magento version mapping will look like this:

cma.js
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    // ... other configurations
    configuration: {
        php: {
            baseImage: 'ghcr.io/scandipwa/create-magento-app:php-8.1-magento-2.4',
            debugImage: 'ghcr.io/scandipwa/create-magento-app:php-8.1-magento-2.4-debug'
        }
    }
};

Note that we are changing both baseImage and debugImage properties!

After changing the configuration, restart the app to install the new PHP version:

yarn start

And validate the new PHP installation through the CLI:

yarn cli
bash-5.1$ php -v
PHP 8.1.10 (cli) (built: Sep  2 2022 11:17:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.10, Copyright (c), by Zend Technologies

Also, the PHP version will be printed during start command execution:

Installing PHP extensions

By default, only the extensions that are required by Magento are installed. If you need to install any additional extensions, cma.js will have to be changed accordingly:

cma.js
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    // ... other configurations
    configuration: {
        php: {
            extensions: {
                memcached: {
                    command: `apk add --no-cache --virtual .build-deps \\$PHPIZE_DEPS \
                    && pecl install memcached \
                    && docker-php-ext-enable memcached \
                    && apk del -f .build-deps`,
                    dependencies: [
                        'libevent-dev',
                        'libmemcached-dev',
                        'zlib-dev'
                    ]
                }
            }
        }
    }
};

All of this might look complicated, but this object describes the following information for magento-scripts:

  1. PHP Extension name. Defined in configuration.php.extensions as a key for configuration object.

  2. Dependencies required by the extension. Defined in configuration.php.extensions[name].dependencies as an array of strings. Optional.

  3. Command to install the extension inside the project image. Defined in configuration.php.extensions[name].command as a string or as a synchronous function that returns a string or asynchronous function that returns a string. Optional.

  1. Enabling installed extension

  2. Removing build dependencies to save space inside the project image.

cma.js
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    // ... other configurations
    configuration: {
        php: {
            extensions: {
                calendar: {}
            }
        }
    }
};

After you made your changes restart the app for changes to take effect:

yarn start

And validate newly installed extensions through the CLI:

yarn cli
bash$ php -m | grep memcached
memcached
PreviousEnabling SSLNextConfiguring Multi-Store

Last updated 12 months ago

Was this helpful?

The default version of PHP for your project is defined by the Magento version according to Magento System Requirements for and .

- Magento 2.4.7 (+ patches)

- Magento 2.4.4, 2.4.5, 2.4.6 (+ patches)

- Magento 2.3.7, 2.4.0, 2.4.1, 2.4.2, 2.4.3 (+ patches)

- Magento 2.3.3, 2.3.4, 2.3.5, 2.3.6 (+ patches)

- Magento 2.2.10, 2.3.0, 2.3.1, 2.3.2 (+ patches)

To change the PHP version, select the PHP version from the section and then the PHP version with Magento extensions.

For example, you have Magento 2.4.3 project and you want to use The configuration file cma.js will look accordingly:

Some extensions have a separate package that can be integrated into cma.js like !

The current example defines that memcached extension requires 2 dependencies to be installed from : libmemcached-dev and zlib-dev and a command to install the extension itself. The command consists of 4 steps:

Installing build dependencies for extension.

Installing the extension itself from .

The command is written in one line because it will use one instruction inside Dockerfile. Dependencies for extensions are recommended to move to the separate dependencies property because they will be installed together with other dependencies from other extensions in one RUN instruction inside Dockerfile.

You can also install extensions from the . The same utility is shipped in and if you will not define any settings in PHP extension configuration, CMA will install the extension using docker-php-ext-install <extension name> command. Example:

This will install a PHP extension.

To retrieve all extensions that docker-php-ext-install utility can install you can run the following command inside : exec php docker-php-ext-install

Magento 2.4
Magento 2.3
PHP 8.3
PHP 8.2
PHP 8.1
PHP 7.4
PHP 7.3
PHP 7.2
PHP Images
PHP 8.1.
ionCube extension
apk repository
PECL
PECL
RUN
docker-php-ext-install project
official PHP images
calendar
CLI