Managing PHP Project Dependencies with Composer
Composer is a tool that helps find, install and update library packages that your PHP project depends on. Libraries are installed in the project's root directory. The Composer utility is available as part of Plesk. You do not need to install Composer in your project manually. Plesk installs the updates for Composer once a week.
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 createcomposer.json
.composer.lock
- lists all libraries on which the libraries incomposer.json
depend directly and indirectly, thus containing all libraries necessary for your project.
For more information, refer to Composer documentation at https://getcomposer.org/doc/.
Plesk offers two ways to use Composer:
- Through the command line. Refer to the Composer documentation for instructions.
: Use normal environment (not chrooted).
- Through Websites & Domains > Applications. See the instructions below.
Managing PHP Project Dependencies with Composer Through Plesk UI
To find all applications that have composer.json,
so that you can manage dependencies, click Scan in the Applications section. 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.
To install all modules necessary for your project, in Websites & Domains > Applications > Manage My Applications > click the application name in the list > Install Dependencies.
To update module dependencies, run Websites & Domains > Applications > Manage My Applications > click the application name > Update Dependencies.
The Edit Configuration button opens composer.json
in Plesk's Code Editor for manual editing.
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.