Install "Composer" on web hosting packages
Objective
Composer is a dependency manager created for the PHP language. It allows PHP developers to include external libraries in their programs. Composer allows PHP projects to facilitate library distribution and code maintenance. Since the creation of this tool, many good development practices have been proposed and have improved the libraries of the PHP community. These good practices are documented in the form of SRP.
This guide explains how to install Composer and provides an example of usage with a Web Hosting plan.
OVHcloud provides services that you are responsible for with regard to their configuration and management. It is therefore your responsibility to ensure that they function properly.
This guide is designed to help you with common tasks. Nevertheless, we recommend contacting a specialist provider or reach out to the OVHcloud community if you encounter any difficulties. We will not be able to assist you. You can find more information in the Go further section of this guide.
Requirements
- An OVHcloud Web Hosting plan with SSH access
- Access to the OVHcloud Control Panel
Instructions
Access your hosting plan via SSH using our guide to using SSH with your OVHcloud web hosting plan.
Use the command line to check if the PHP version is compatible:
If this is not a proper version, you can configure an alias:
We recommend staying in the root folder of your Web Hosting in order to prevent your Composer files from being publicly accessible. Next, run this command:
Composer is now available on your Web Hosting.
Use cases
If you want to install Symfony 2, you can for example run the following command:
You can also use the OVHcloud API from your hosting using the official wrapper. To do this, add a file named composer.json containing the list of dependencies you need. Here is an example of this file with the OVHcloud API wrapper:
To install it, run the following command in the same folder:
To use this library, please refer to the documentation, as well as the code, available on GitHub.
Go further
For specialised services (SEO, development, etc.), contact OVHcloud partners.
If you would like assistance using and configuring your OVHcloud solutions, please refer to our support offers.
Join our community of users.