A GitHub Action to streamline installation of Composer dependencies.
ramsey/composer-install is a GitHub Action to streamline installation of Composer dependencies in workflows. It installs your Composer dependencies and caches them for improved build times.
This project adheres to a code of conduct. By participating in this project and its community, you are expected to uphold this code.
This GitHub Action requires PHP and Composer. One way to ensure you have both is to use the Setup PHP GitHub Action.
The step that sets up PHP and Composer for your environment must come before the ramsey/composer-install step.
Use ramsey/composer-install as step within a job. This example also shows use of the Setup PHP action as a step.
- uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
- uses: "ramsey/composer-install@v1"
💡 There is no need to set up a separate caching step since ramsey/composer-install handles this for you.
The dependency-versions
input parameter allows you to select whether the job
should install the locked, highest, or lowest versions of Composer dependencies.
Valid values are:
-
locked
: (default) installs the locked versions of Composer dependencies (equivalent to runningcomposer install
) -
highest
: installs the highest versions of Composer dependencies (equivalent to runningcomposer update
) -
lowest
: installs the lowest versions of Composer dependencies (equivalent to runningcomposer update --prefer-lowest
)
For example:
- uses: "ramsey/composer-install@v1"
with:
dependency-versions: "lowest"
ramsey/composer-install always passes the --no-interaction
, --no-progress
,
and --ansi
options to the composer
command. If you'd like to pass additional
options, you may use the composer-options
input parameter.
For example:
- uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-reqs"
If your composer.json
is located in a sub-folder (e.g.: packages/api
),
you must use working-directory
input to get the action working properly.
For example:
- uses: "ramsey/composer-install@v1"
with:
working-directory: "packages/api"
GitHub Workflows allow you to set up a job matrix, which allows you to configure multiple jobs for the same steps by using variable substitution in the job definition.
Here's an example of how you might use the dependency-versions
and
composer-options
input parameters as part of a job matrix.
strategy:
matrix:
php:
- "7.3"
- "7.4"
- "8.0"
dependencies:
- "lowest"
- "highest"
steps:
- uses: "actions/checkout@v2"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php }}"
- uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
Contributions are welcome! Before contributing to this project, familiarize yourself with CONTRIBUTING.md.
The ramsey/composer-install GitHub Action is copyright © Ben Ramsey and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.