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.