Using Composer in MODX Cloud
Modern PHP applications virtually mandate that Composer is used. Fortunately, MODX Cloud supports it by default with a quick trip to the command line:
-
From the Cloud instance where you wish to use Composer, make note of the internal Cloud URL, and SSH credentials.
-
Open your terminal, shell or Putty to login via
ssh
into your Cloud instance -
Download and install the advanced tool scripts (you’ll get wp-cli, too):
sh -c "$(curl https://modx.co/scripts/install.sh)"
- Either logout and back into the
ssh
session for Composer to be available. Or, use thesource
command provided. - Use the following command to confirm that Composer is installed:
composer --version
- That is all.
Development Mode
By default, using Composer in MODX Cloud assumes you're using it as a production environment. As such, when running composer install
you will find that it will not install any of the items identified in the require-dev
section of your composer.json.
To allow for the installation of your development dependencies you'll need to either change the /home/.profile
file where it says:
export COMPOSER_NO_DEV=1
to
export COMPOSER_NO_DEV=0
which will disable this.
The better solution if you're eventually going to make this your production environment is to use the following command which will override the COMPOSER_NO_DEV=1
in the .profile
.
COMPOSER_NO_DEV=0 composer install