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:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
3. Install Composer into the current directory.
php composer-setup.php --install-dir=./ --filename=composer
Tip: If needed, you can move to the required directory before the operation or adjust the path via the install-dir parameter. However, you cannot install to the /usr/local/bin/ directory with the initial Composer instance.
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).
php -r "unlink('composer-setup.php');"
That’s all! The latest version of the Composer is successfully installed and is ready for use.
Powered by BetterDocs
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.