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.
Join the DZone community and get the full member experience.Join For Free
to 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:
- generate an ssh keypair.
- add your public ssh key to the dashboard.
- access your account via ssh protocol.
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
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
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
- for nginx php :
export path=$path:/var/lib/nginx/bin echo 'export path=$path:/var/lib/nginx/bin' >> ~/.bash_profile
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:
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 .
Published at DZone with permission of Tetiana Markova, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.