Configuring PHP

PHP configuration is stored within the cma.js file:

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

Changing the PHP version

The default version of PHP supplied with Create Magento App is 7.4.13. In order to change it, cma.js will have to be adjusted accordingly:

module.exports = {
magento: {
first_name: 'Scandiweb',
last_name: 'Developer',
user: 'admin',
password: 'scandipwa123',
adminuri: 'admin',
mode: 'developer',
},
configuration: {
php: {
version: '7.4.14'
}
}
};

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-3.2$ php -v
PHP 7.4.14 (cli) (built: Mar 16 2021 16:21:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans

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:

module.exports = {
magento: {
first_name: 'Scandiweb',
last_name: 'Developer',
user: 'admin',
password: 'scandipwa123',
adminuri: 'admin',
mode: 'developer',
},
configuration: {
php: {
extensions: {
memcached: {},
sphinx: {
version: '1.3.3'
}
}
}
}
};

You can specify the version of the extension explicitly (like with sphinx) or install the latest available version automatically by leaving the object empty (like with memcached). Restart the app for changes to take effect:

yarn start

And validate newly installed extensions through the CLI:

yarn cli
bash-3.2$ php -m | grep "memcached\|sphinx"
memcached
sphinx

FAQ

My build failed after changing the PHP version, why?

Versions of PHP 7.4 older than 7.4.13 will not compile on Mac as of magento-scripts 1.3.0.

Before changing the PHP version, make sure that it's supported by the Magento version you're using. By default, Create Magento App runs on Magento 2.4 that requires PHP of version 7.4.x. Please check the Magento 2.4 system requirements to see the list of supported PHP versions.

If the PHP version is correct and you have this issue, you should examine the build logs. Each failed build of Create Magento App supplies you with a build log and the location of that log is displayed at the end of the build:

Please checkout the build log file for more details:
tail /Users/user/.phpbrew/build/php-7.4.0/build.log
error Command failed with exit code 1.

My build failed after installing PHP extensions, why?

Some PHP extensions require certain binaries to be installed on your machine and the build will fail otherwise. The path to log file will be displayed in the console when the build fails:

Log stored at: /Users/user/.phpbrew/build/php-7.4.13/ext/memcached/build.log

You can print this log with tail command to see the output:

checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located

In this case, the libmemcached library is missing on the machine and has to be installed for build to succeed.