Composer is a popular dependency manager for PHP, borrowing from the ideas of npm (node) and bundler (ruby). It’s super easy to install and use Composer on the Enscale PaaS.
Connect to your Apache PHP or Nginx PHP node from one of your Enscale environments using the Enscale SSH gateway. Change your working directory to a suitable one of your choice, such as /var/www/webroot:
-bash-4.1$ cd /var/www
Then simply execute the Composer installer as normal:
-bash-4.1$ curl -sS https://getcomposer.org/installer | php
That’s all there is to it! Composer is installed and ready to use. But, we can also make a few little optimisations to make life easier:
-bash-4.1$ mkdir ~/bin
-bash-4.1$ mv ~/composer.phar ~/bin/composer
This does 2 things at once:
This step allows you to effortlessly execute composer from any working directory on the server, without having to write out its full path; otherwise you’d need to write /var/www/bin/composer (or /var/lib/nginx/bin/composer) each time you want to call it!
-bash-4.1$ export PATH=$PATH:/var/www/bin
-bash-4.1$ echo 'export PATH=$PATH:/var/www/bin' >> ~/.bash_profile
-bash-4.1$ export PATH=$PATH:/var/lib/nginx/bin
-bash-4.1$ echo 'export PATH=$PATH:/var/lib/nginx/bin' >> ~/.bash_profile
Bash offers various startup files. For our purposes, ~/.bash_profile
is fine because every SSH login via the gateway is invoked as an interactive login shell; you could equally use ~/.bashrc
providing that you also call it from your ~/.bash_profile
.
To confirm that the above steps have worked:
-bash-4.1$ composer about
Composer - Package Management for PHP
Composer is a dependency manager tracking local dependencies of your projects and libraries.
See http://getcomposer.org/ for more information.
Now you can use Composer to manage dependencies within your PHP projects.