{"id":15625840,"url":"https://github.com/php-actions/composer","last_synced_at":"2025-04-08T08:17:19.207Z","repository":{"id":36185773,"uuid":"203149124","full_name":"php-actions/composer","owner":"php-actions","description":"Use the Composer CLI in your Github Actions.","archived":false,"fork":false,"pushed_at":"2024-04-30T17:50:02.000Z","size":224,"stargazers_count":174,"open_issues_count":15,"forks_count":54,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T15:48:57.519Z","etag":null,"topics":["actions","ci","composer","github","github-actions","php"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-actions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["g105b"]}},"created_at":"2019-08-19T10:16:15.000Z","updated_at":"2024-07-29T14:03:05.000Z","dependencies_parsed_at":"2024-06-18T11:11:44.441Z","dependency_job_id":"b9bce917-fc71-4afa-9ba5-910e72428d65","html_url":"https://github.com/php-actions/composer","commit_stats":{"total_commits":200,"total_committers":24,"mean_commits":8.333333333333334,"dds":"0.16000000000000003","last_synced_commit":"da5a2cb77d99e639acfee65b60a70332793fcd6f"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-actions%2Fcomposer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-actions%2Fcomposer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-actions%2Fcomposer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-actions%2Fcomposer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-actions","download_url":"https://codeload.github.com/php-actions/composer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801175,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","ci","composer","github","github-actions","php"],"created_at":"2024-10-03T10:06:30.935Z","updated_at":"2025-04-08T08:17:19.170Z","avatar_url":"https://github.com/php-actions.png","language":"Shell","readme":"\u003cimg src=\"http://159.65.210.101/php-actions.png\" align=\"right\" alt=\"PHP Actions for Github\" /\u003e\n\nUse the Composer CLI in your Github Actions.\n============================================\n\nComposer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage (install/update) them for you.\n\nIf you are running tests like [PHPUnit][php-actions-phpunit], [phpspec][php-actions-phpspec] or [Behat][php-actions-behat] in your Github actions, chances are you will need to install your project's dependencies using Composer.\n\nAn example repository has been created at https://github.com/php-actions/example-composer to show how to use this action in a real project. The repository also depends on a private dependency and uses SSH keys for authentication.\n\nUsage\n-----\n\nCreate your Github Workflow configuration in `.github/workflows/ci.yml` or similar.\n\n```yaml\nname: CI\n\non: [push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v3\n    - uses: php-actions/composer@v6\n    # ... then your own project steps ...\n```\n\n### Version numbers\n\nThis action is released with semantic version numbers, but also tagged so the latest major release's tag always points to the latest release within the matching major version.\n\nPlease feel free to use `uses: php-actions/composer@v6` to always run the latest version of v6, or `uses: php-actions/composer@v6.0.0` to specify the exact release.\n\n\nRunning custom commands\n-----------------------\n\nBy default, adding `- uses: php-actions/composer@v6` into your workflow will run `composer install`, as `install` is the default command name. The `install` command will be provided with a default set of arguments (see below).\n\nYou can issue custom commands by passing a `command` input, like so:\n\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      with:\n        command: your-command-here\n```\n\nPassing arguments\n-----------------\n\nAny arbitrary arguments can be passed to composer by using the `args` input, however there are a few inputs pre-configured to handle common arguments. All inputs are optional. Please see the following list:\n\n+ `interaction` - Whether to ask any interactive questions - yes / no (default `no`)\n+ `dev` - Whether to install dev packages - yes / no (default `yes`)\n+ `progress` - Whether to output download progress - yes / no (default `no`)\n+ `quiet` - Whether to suppress all messages - yes / no (default `no`)\n+ `args` - Optional arguments to pass - no constraints (default _empty_)\n+ `only_args` - Only run the desired command with this args. Ignoring all other provided arguments(default _empty_)\n+ `php_version` - Choose which version of PHP you want to use - x.y (default `latest`) (e.g. `7.4.29`, `8.2`, or any version listed on https://www.php.net/releases/index.php)\n+ `version` - Choose which version of Composer you want to use - default `latest` (e.g. `1.x`, `1.10.26`, `2.x`, `2.2.x`, or any exact version listed on https://getcomposer.org/download/)\n+ `memory_limit` - Sets the composer memory limit - (default _empty_)\n+ `container_workdir` - Sets the aplication workdir inside container - (default /app)\n\nThere are also SSH input available: `ssh_key`, `ssh_key_pub` and `ssh_domain` that are used for depending on private repositories. See below for more information on usage.\n\nExample of a yaml config that does not want to install dev packages, and passes the `--profile` and `--ignore-platform-reqs` arguments:\n\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      with:\n        dev: no\n        args: --profile --ignore-platform-reqs\n```\n\nUsing different versions of PHP or Composer\n-------------------------------------------\n\nThis action runs on a custom base image, available at https://github.com/php-actions/php-build which allows for switching the active PHP version on-the-fly, and this repository allows switching of Composer versions on-the-fly.\n\nUse the following inputs to run a specific PHP/Composer version combination:\n\n+ `php_version` Available versions: `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1` (default: `latest` aka: `8.1`)\n+ `version` Available versions: `latest`, `preview`, `snapshot`, `1.x`, `2.x`, `2.2.x` or an exact version like `2.5.8` (default: `latest`)\n\nMake sure to put the PHP version number in quotes, otherwise YAML will interpret e.g. `8.0` as `8` which means latest 8.x, not 8.0.\n\nExample configuration that runs Composer version 1 on PHP version 7.1:\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      with:\n        php_version: \"7.1\"\n        version: 1\n```\n\nExecute composer install in a different folder\n-------------------------------------------\n\n```yaml\n    - name: Install dependencies\n      uses: \"php-actions/composer@v6\"\n      env:\n        COMPOSER: \"composer.json\"\n      with:\n        php_version: \"5.6.40\"\n        version: \"2.2\"\n        args: \"--ignore-platform-reqs --optimize-autoloader\"\n        working_dir: \"my/different/folder\"\n```\n\nIncluding PHP Extensions\n-------------------------------------------\n\nThis action includes the [extensions that Composer suggests](https://github.com/composer/composer/blob/master/composer.json#L44) by default. To include additional PHP extensions in your action steps, set the `php_extensions` input with any of the [supported extension names](https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions) separated by spaces.\n\nExample configuration that runs Composer version 2 on PHP version 7.4 with the Redis and Exif extensions enabled:\n\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      with:\n        php_version: \"7.4\"\n        php_extensions: redis exif\n        version: 2.x\n```\n\nCaching dependencies for faster builds\n--------------------------------------\n\nGithub actions supports dependency caching, allowing Composer downloads to be cached between workflows, as long as the `composer.lock` file has not changed. This produces much faster builds, as the `composer install` command does not have to download files over the network at all if the cache is valid.\n\nExample workflow (taken from https://github.com/PhpGt/Database):\n\n```yaml\nname: CI\n\non: [push]\n\njobs:\n  build:\n    runs-on: [ubuntu-latest]\n    \n    steps:\n    - uses: actions/checkout@v3\n\n    - name: Cache Composer dependencies\n      uses: actions/cache@v3\n      with:\n        path: /tmp/composer-cache\n        key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}\n      \n    - uses: php-actions/composer@v6\n\n    ...      \n```\n\nIn the example above, the \"key\" is passed to the Cache action that consists of a hash of the composer.lock file. This means that as long as the contents of composer.lock doesn't change between workflows, the Composer cache directory will be persisted between workflows.\n\nInstalling private repositories\n-------------------------------\n\nTo install from a private repository, SSH authentication must be used. Generate an SSH key pair for this purpose and add it to your private repository's configuration, preferable with only read-only privileges. On Github for instance, this can be done by using [deploy keys][deploy-keys]. \n\nAdd the key pair to your project using  [Github Secrets][secrets], and pass them into the `php-actions/composer` action by using the `ssh_key` and `ssh_key_pub` inputs. If your private repository is stored on another server than github.com, you also need to pass the domain via `ssh_domain`. If the private repository is configured to use a non-standard SSH port, you can configure this by passing `ssh_port`.\n\nExample yaml, showing how to pass secrets:\n\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      with:\n        ssh_key: ${{ secrets.ssh_key }}\n        ssh_key_pub: ${{ secrets.ssh_key_pub }}\n```\n\nThere is an example repository available for reference at https://github.com/php-actions/example-composer that uses a private dependency. Check it out for a live working project.\n\n### HTTP basic authentication\n\nIt's recommended to use SSH keys for authentication, but sometimes HTTP basic authentication is the only tool available at the time. In order to use this authentication mechanism as securely as possible, please follow these steps:\n\n1) Create a [personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) for the Github account you wish to authenticate with.\n\n2) Create a new GitHub Secret called `PAT` with a value of personal access token.\n\n3) Pass this secret to COMPOSER_AUTH variable:\n\n```yaml\njobs:\n  build:\n\n    ...\n\n    - name: Install dependencies\n      uses: php-actions/composer@v6\n      env:\n        COMPOSER_AUTH: '{\"github-oauth\": {\"github.com\": \"${{ secrets.PAT }}\"} }'\n```\n\n4) Now, any connections Composer makes to GitHub.com will use your HTTP basic auth credentials, which is essentially the same as being logged in as you, so your private repositories will now be available to Composer.\n\n***\n\nIf you found this repository helpful, please consider [sponsoring the developer][sponsor].\n\n[php-actions-phpunit]: https://github.com/marketplace/actions/phpunit-php-actions \n[php-actions-phpspec]: https://github.com/marketplace/actions/phpspec-php-actions \n[php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions \n[deploy-keys]: https://docs.github.com/en/developers/overview/managing-deploy-keys\n[secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets\n[sponsor]: https://github.com/sponsors/g105b\n","funding_links":["https://github.com/sponsors/g105b"],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-actions%2Fcomposer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-actions%2Fcomposer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-actions%2Fcomposer/lists"}