composer - Dependency Manager for PHP

New in version 1.6.

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • php
  • composer installed in bin path (recommended /usr/local/bin)

Parameters

Parameter Choices/Defaults Comments
apcu_autoloader
bool

(added in 2.7)
    Choices:
  • no ←
  • yes
Uses APCu to cache found/not-found classes

aliases: apcu-autoloader
arguments
(added in 2.0)
Composer arguments like required package, version and so on.
classmap_authoritative
bool

(added in 2.7)
    Choices:
  • no ←
  • yes
Autoload classes from classmap only.
Implicitely enable optimize_autoloader.
Recommended especially for production, but can take a bit of time to run.

aliases: classmap-authoritative
command
(added in 1.8)
Default:
install
Composer command like "install", "update" and so on.
executable
(added in 2.4)
Path to PHP Executable on the remote host, if PHP is not in PATH.

aliases: php_path
global_command
bool

(added in 2.4)
    Choices:
  • no ←
  • yes
Runs the specified command globally.

aliases: global-command
ignore_platform_reqs
bool

(added in 2.0)
    Choices:
  • no ←
  • yes
Ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these.

aliases: ignore-platform-reqs
no_dev
bool
    Choices:
  • no
  • yes ←
Disables installation of require-dev packages (see --no-dev).

aliases: no-dev
no_plugins
bool
    Choices:
  • no ←
  • yes
Disables all plugins ( see --no-plugins ).

aliases: no-plugins
no_scripts
bool
    Choices:
  • no ←
  • yes
Skips the execution of all scripts defined in composer.json (see --no-scripts).

aliases: no-scripts
optimize_autoloader
bool
    Choices:
  • no
  • yes ←
Optimize autoloader during autoloader dump (see --optimize-autoloader).
Convert PSR-0/4 autoloading to classmap to get a faster autoloader.
Recommended especially for production, but can take a bit of time to run.

aliases: optimize-autoloader
prefer_dist
bool
    Choices:
  • no ←
  • yes
Forces installation from package dist even for dev versions (see --prefer-dist).

aliases: prefer-dist
prefer_source
bool
    Choices:
  • no ←
  • yes
Forces installation from package sources when possible (see --prefer-source).

aliases: prefer-source
working_dir
Directory of your project (see --working-dir). This is required when the command is not run globally.
Will be ignored if global_command=true.

aliases: working-dir

Notes

Note

  • Default options that are always appended in each execution are –no-ansi, –no-interaction and –no-progress if available.
  • We received reports about issues on macOS if composer was installed by Homebrew. Please use the official install method to avoid issues.

Examples

# Downloads and installs all the libs and dependencies outlined in the /path/to/project/composer.lock
- composer:
    command: install
    working_dir: /path/to/project

- composer:
    command: require
    arguments: my/package
    working_dir: /path/to/project

# Clone project and install with all dependencies
- composer:
    command: create-project
    arguments: package/package /path/to/project ~1.0
    working_dir: /path/to/project
    prefer_dist: yes

# Installs package globally
- composer:
    command: require
    global_command: yes
    arguments: my/package

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Dimitrios Tydeas Mengidis (@dmtrs)
  • René Moser (@resmo)

Hint

If you notice any issues in this documentation you can edit this document to improve it.