composer_project_dependencies

composer_project_dependencies installs what a PHP application's composer.lock lists into the application's vendor directory, with composer install and without prompts, as the application's account. The task names the directory on the node that holds composer.json and composer.lock, usually a release directory or a checkout.

The five lock file modules work the same way: the lock file is never rewritten, and a record in the lock file directory makes a rerun unchanged. That is in install what an application's lock file lists and in the design's what the lock file modules share. The rules of every language and tool installer, such as run_as_user_account, composer_program_path, and env, are in what the installers share.

Set up

PHP comes from the distribution's packages, and Composer from a pinned download of its publisher:

- when: {equals: ["{{ .node.package_manager }}", apt]}
  apt_package: {packages: [{name: php-cli, version: newest_when_first_installed}]}
- when: {equals: ["{{ .node.package_manager }}", dnf]}
  dnf_package: {packages: [{name: php-cli, version: newest_when_first_installed}]}

- download:
    url: https://getcomposer.org/download/2.8.4/composer.phar
    sha256: "c4c4e2e1beab0ea04e0bd042a5dbba9feda1fbf5eda0d36203958edd343c0a8a"
    path: /usr/local/bin/composer
    permissions_mode: "0755"

Inputs

  • lock_file_dir (string; required): the directory on the node that holds composer.json and composer.lock, usually a release directory or a checkout
  • run_as_user_account (string; required): the application's account, which runs Composer: Composer runs the packages' scripts
  • include_development_dependencies (boolean; required): false leaves out what composer.json lists under require-dev; true installs it
  • composer_program_path (string; default found on the standard path): a written value must be absolute; the composer program to run when it is not composer on the standard path; its directory comes first in PATH
  • env (mapping; optional): environment variables for Composer, such as COMPOSER_AUTH for a private repository; values may be secrets

Outputs

The node task's result holds these fields. A later node task reads them as .node_tasks.<id>.<field>, where <id> is the node task's id.

  • status
  • change
  • value

What a dryrun reports

Compares the record and reports unchanged or would change with the reason, and the operations composer install --dry-run lists in value.operations; a lock file directory that does not exist yet, or a lock file or manifest that an earlier node task would change, is not checked.

Retries and time limits

Bounded automatic retries by default; retry: false turns them off.

The node task takes the time limits time_limit and time_limit_per_try; without them, the project's node_task_defaults apply. mmx describe-module task describes the settings every node task accepts.

Examples

Install a release's packages without development dependencies

- composer_project_dependencies:
    lock_file_dir: /srv/myapp/releases/v1.4.2
    run_as_user_account: myapp
    include_development_dependencies: false

include_development_dependencies is required: false leaves out what composer.json lists under require-dev. On the node, MMX runs composer install without prompts in /srv/myapp/releases/v1.4.2, as the account myapp. It installs exactly what composer.lock lists into vendor. After a successful installation, MMX writes the record .mmx-composer-project-dependencies in the same directory.

Tested on

Distributions: Debian 12 and 13, Ubuntu 24.04 and 26.04, Rocky Linux 9, AlmaLinux 10.

The suite language_installers.py runs on Debian 12 and 13, Ubuntu 24.04 and 26.04, Rocky Linux 9, and AlmaLinux 10, with PHP from the distribution's packages and Composer 2.8.4 from a pinned download. Its Composer project takes its packages from a path repository, so it needs no download.

Why it works this way

  • A changed manifest reaches the installer's lock-file check. The shared installation record prevents an old successful installation from hiding a manifest change.
  • A written program path is absolute. Leaving the path out uses the installer's normal program selection, as the shared inputs explain.

This page is docs/reference/modules/composer_project_dependencies.md in the MMX repository.