Image

Managing PHP Project Dependencies with PHP Composer

PHP Composer is an additional tool with which you can find, install and update the library packages on which your project written in PHP depends. This tool allows you to reduce the time for developing a project using ready-made libraries from a common catalog. PHP libraries are installed in the root directory of the project. You do not need to install PHP Composer in the project manually, it is already available in the hosting control panel and you can immediately start working with it. The control panel installs updates for PHP Composer weekly.

For example: you are developing a website and you need to add functionality to send emails (notifications) to your site so that you don’t write this code, you can load the necessary library and link it to your project, thereby saving time for writing code .

PHP Composer uses two files for storing the list of modules necessary for the project:

  • composer.json - lists libraries on which your project depends directly.

Add file composer.json to the root directory of your project and specify packages. You can use the ‘composer init' command to create composer.json.

  • composer.lock - lists all libraries on which the libraries in composer.json depend directly and indirectly, thus containing all libraries necessary for your project.

For more information, refer to the Composer documentation at https://getcomposer.org/doc/.

The hosting control panel offers two ways to use PHP Composer:

  • Using the command line. See the documentation for Composer for instructions. (Note: Use the usual environment (not chrooted). For tariffs with SSH (Business and Business +)
  • Via Sites and Domains> Applications. See instructions below.

Using the UI for Managing PHP Project Dependencies with PHP Composer



To find all applications that have composer.json, so that you can manage dependencies, click Scan in Websites & Domains > Applications. The applications will appear in the list in the Applications section. The commands described below are available only for applications with the composer.json file.

  • Installing Dependencies

To install all modules necessary for your project, in Websites & Domains > Applications > Manage My Applications > click the application name in the list > Install Dependencies.

  • Updating Dependencies

To update module dependencies, run Websites & Domains > Applications > Manage My Applications > click the application name > Update Dependencies.

  • Editing Dependencies

The Edit Configuration button opens composer.json in Panel Code Editor for manual editing.

  • Removing Dependencies Management from Your App

When you click Remove, the application no longer appears in the list of applications in My Apps. However, the composer.json and composer.lock files remain in the application directory, so you can add the application to the list by clicking Scan.