What is it?
Composer is an application-level package manager for PHP. In simple words, Composer manages packages per-project basis, installing them in a directory (e.g. vendor) inside your project.
How to use it?
Composer and Composer2 (meant for PHP 8.0 versions) are already pre-installed on all Shared (except for Shared Single and Single WordPress) and Cloud plans. You can confirm that by logging in to your hosting account via SSH and using this command:
composer. More information about that can be found here:
Using Composer can be done like this:
Find a preferred PHP package on Packagist
Navigate to your desired directory on your hosting account and copy the command shown on the top of Packagist, we will use gumlet/php-image-resize as an example:
Paste this code to the terminal, you can see how composer.json, composer.lock files and Vendor directory will be created:
Now you can go ahead and test the package out, simply create/edit your existing PHP file. Comprehensive examples can always be found on the Packagist website.
That’s it! Now you know how to use Composer 😊
In case you are encountering any issues you can check this article: Solving possible Composer errors
If you are using PHP 8.0 you need to specify your commands as
Comprehensive tutorial for installing Composer for Linux, macOS or Windows