Install PHP Composer via SSH for Dependencies Management of Your Cloud App

DZone 's Guide to

Install PHP Composer via SSH for Dependencies Management of Your Cloud App

In this post we take a look at how to install the popular PHP dependency management tool, Composer, via SSH to help with our cloud-based PHP applications.

· Cloud Zone ·
Free Resource

php composer guideTo consolidate and centralize the management of dependencies can be a real problem for complex cloud applications. That is why the right decision here is to use already-proven, on the market dependency management tools.

Composer is one of the most popular dependency management solutions for PHP, inspired by node’s npm and ruby’s bundler. It smartly manages all the required libraries and packages for your application. Running on a per-project basis, Composer determines which versions of which packages your project depends on and installs them in a working directory. Moreover, this tool provides automatic updates load, allowing to keep your packages actual.

Follow the instructions below to install PHP Composer via Jelastic SSH Gateway and perform its configuration, that will enable us to execute it from any working directory throughout a server.

1. In order to run the Composer installation by means of  Jelastic SSH Gateway, you need to:

Once you’ve established SSH connection to your Apache PHP or NGINX PHP server (Apache 2.4 in our example), you can easily integrate Composer into your project.

2. Run the Composer installer from inside your server working directory to download the appropriate composer.phar archive:

curl -sS https://getcomposer.org/installer | php

php composer

3. Rename the composer.phar file to just “composer” and move it to the private bin directory with the below commands:

mkdir ~/bin mv ~/composer.phar ~/bin/composer

install php composer

4. Now, let’s add Composer to the server PATH variable in order to be able to further execute it from any server directory. In such a way, you won’t have to write out the full path (i.e. /var/www/bin/composer) for calling this dependencies manager when necessary. 

For that, run one of the following commands depending on used application server:

  • for Apache PHP
export PATH=$PATH:/var/www/bin echo 'export PATH=$PATH:/var/www/bin' >> ~/.bash_profile

php composer ssh

  • for NGINX PHP:
export PATH=$PATH:/var/lib/nginx/bin echo 'export PATH=$PATH:/var/lib/nginx/bin' >> ~/.bash_profile

php composer path
 That’s it! Composer is added to your PATH variable now.

5. Everything is already set up! You can run the following command in order to ensure that PHP Composer works as intended:

composer about

php composer manager

Great! Start using Composer on your Apache or NGINX server and easily control dependencies within your PHP projects. 

If you face any issues while installing PHP Composer via Jelastic SSH Gateway, feel free to appeal for our technical experts’ assistance at Stackoverflow.

cloud, jelastic composer, php, ssh

Published at DZone with permission of Tetiana Markova , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}