Install PHP Composer via SSH for Smart Dependencies Management of Your Cloud Application

By November 15, 2016 HowTo No Comments
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

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 solution 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 instruction 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.

Install Composer

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' >> ~/.bashrc

php composer ssh

  • for NGINX PHP:
export PATH=$PATH:/var/lib/nginx/bin
еcho 'export PATH=$PATH:/var/lib/nginx/bin' >> ~/.bashrc

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.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates