PHP Composer for Smart Dependency Management of Your Cloud Applications
Composer is one of PHP’s most popular dependency management tools inspired by the node’s npm and ruby’s bundler. It will smartly manage 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 the autoload feature to keep your packages up-to-date.
The Composer is integrated into all PHP application servers (Apache, NGINX, LiteSpeed, LEMP, and LSSMP) by default. It is installed to the /usr/local/bin folder, which is added to the PATH variable, making Composer operable from anywhere on the node via the composer shortcut (e.g. composer about). Additionally, if the project has a composer.json file, Composer can manage dependencies directly during the installation using the Post-Deploy hook script. All you need to do is move to your project directory and run the composer install command:
You are automatically provided with the latest version of Composer during the node creation. However, if a newer version of Composer is released, you can easily get it without the necessity of recreating a whole container. Follow the next steps to install the latest composer version into your PHP container:
1. Connect to the appropriate node via SSH. For example, using the built-in Web SSH.
2. Download Composer installer with the following command:
3. Install Composer into the current directory.
4. Let’s run this local version of the Composer (i.e. using relative or absolute path) to ensure that everything works as expected. For example:
Tip: If the dependency manager works fine, we recommend removing the installer (as it’s not needed anymore).
That’s all! The latest version of the Composer is successfully installed and is ready for use.