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 the
composer.json
file to the root directory of your project and
specify packages. You can use thecomposer init
command to
createcomposer.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.
You can use Composer in two ways:
-
Via the command line. Refer to the Composer documentation for instructions.
Note: Use normal environment (not the chroot one).
-
Via the Plesk interface (Websites & Domains > the domain > PHP Composer).
To start working with Composer via the Plesk interface, you need to locate the
composer.json
file first.
To do so, go to Websites & Domains > the subscription whose root directory
containscomposer.json
you put earlier > PHP Composer and then click Scan.Once
composer.json
is located, you can perform the following actions:- To install dependencies, click Install next to Package Dependencies.
- To update dependencies, click Update next to Package Dependencies.
Note: Before updating dependencies, we recommend that you click “How update works” to see what updates are available and
how they can affect your application. Dependencies updates vary: they can be major, minor, or patch. Major updates can break your application,
while minor and patch ones are usually safe. “How update works” helps you see a possible outcome and assess the risk of updates.- To edit dependencies, click Edit composer.json, edit the file in the opened pane,
and then click Update.