{"id":31009215,"url":"https://github.com/antfroger/php-version-action","last_synced_at":"2026-04-11T15:38:19.001Z","repository":{"id":311724883,"uuid":"1022270985","full_name":"antfroger/php-version-action","owner":"antfroger","description":"A GitHub Action that automatically determines PHP versions for your workflows by reading your composer.json file.","archived":false,"fork":false,"pushed_at":"2025-09-08T14:56:51.000Z","size":546,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-08T16:41:12.592Z","etag":null,"topics":["ci","composer","composer-plugin","github-actions","github-actions-ci","php","php-library","php-versions","versions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antfroger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-07-18T18:45:44.000Z","updated_at":"2025-09-08T14:56:47.000Z","dependencies_parsed_at":"2025-08-26T08:31:23.099Z","dependency_job_id":"c13f6255-b891-40d5-a58a-d5778b701c35","html_url":"https://github.com/antfroger/php-version-action","commit_stats":null,"previous_names":["antfroger/php-version-action"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/antfroger/php-version-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fphp-version-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fphp-version-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fphp-version-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fphp-version-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antfroger","download_url":"https://codeload.github.com/antfroger/php-version-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fphp-version-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274915634,"owners_count":25373194,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ci","composer","composer-plugin","github-actions","github-actions-ci","php","php-library","php-versions","versions"],"created_at":"2025-09-13T04:04:34.538Z","updated_at":"2025-12-31T00:58:08.884Z","avatar_url":"https://github.com/antfroger.png","language":"TypeScript","readme":"# PHP Version Action\n\n[![Super-Linter](https://github.com/antfroger/php-version-action/actions/workflows/linter.yml/badge.svg)](https://github.com/antfroger/php-version-action)\n![CI](https://github.com/antfroger/php-version-action/actions/workflows/ci.yml/badge.svg)\n[![Check dist](https://github.com/antfroger/php-version-action/actions/workflows/check-dist.yml/badge.svg)](https://github.com/antfroger/php-version-action/workflows/check-dist.yml)\n[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)\n[![Release](https://img.shields.io/github/release/antfroger/php-version-action.svg?style=flat-square)](https://github.com/antfroger/php-version-action/releases)\n\nA GitHub Action that automatically determines PHP versions for your workflows by reading your `composer.json` file. This\naction eliminates the need to hardcode PHP versions in your GitHub Actions workflows, making them more maintainable and\nautomatically up-to-date.\n\n## Overview\n\nFrom your `composer.json` and the released versions of PHP (read from [PHP.Watch](https://php.watch)), this action\ndetermines a matrix of all the versions to be used as a build matrix in your GitHub Actions.\n\nIt also exposes the minimal and latest versions as variables to your workflow.\n\n- **Automatic PHP Version Detection**: Reads PHP version requirements from your `composer.json` file\n- **Smart Version Matrix**: Generates a matrix of PHP versions from minimum to latest supported\n- **Real-time Updates**: Fetches current PHP version information from [PHP.watch](https://php.watch)\n- **Flexible Outputs**: Provides minimal, latest, and matrix versions for different use cases\n- **SemVer Compatible**: Properly handles version constraints like `\u003e=8.1`, `^8.0`, etc.\n\n## Inputs\n\n| Name                | Description                                              | Required | Default |\n| ------------------- | -------------------------------------------------------- | -------- | ------- |\n| `working-directory` | Directory containing your composer.json file             | Yes      | `.`     |\n| `unstable`          | Include unstable PHP versions (beta, release candidates) | Yes      | `false` |\n| `unsupported`       | Include unsupported versions (EOL, no security updates)  | Yes      | `true`  |\n\n## Outputs\n\n| Name                   | Description                                                | Example                        |\n| ---------------------- | ---------------------------------------------------------- | ------------------------------ |\n| `composer-php-version` | The PHP version requirement from composer.json             | `\u003e=8.1 \u003c=8.4`                  |\n| `minimal`              | The minimum supported PHP version meeting the requirements | `8.1`                          |\n| `latest`               | The latest available PHP version meeting the requirements  | `8.4`                          |\n| `matrix`               | A (stringified) array of PHP versions from min to latest   | `[\"8.1\", \"8.2\", \"8.3\", \"8.4\"]` |\n\n## 📖 Examples\n\n### Use Specific Version\n\nLet's say you specified `\u003e=8.1` as PHP requirements in your `composer.json` file. 8.1 is the minimal supported version\nand you want your workflow to set up PHP with the version 8.1 using the shivammathur/setup-php action:\n\n```yaml\nname: My workflow\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  my-workflow:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v5\n\n      - name: Get PHP Versions\n        id: php-version\n        uses: antfroger/php-version-action@v1\n\n      - name: Setup PHP (Minimal)\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ steps.php-version.outputs.minimal }}\n          tools: composer:v2\n\n      - name: Test\n        run: echo \"run your tests\"\n```\n\n![Test with minimal](doc/test-minimal.png)\n\nIf you want to do the same but using the latest PHP version that meets the requirements defined in `composer.json`, you\nsimply need to replace `steps.php-version.outputs.minimal` by `steps.php-version.outputs.latest`\n\n### Multi-version Testing\n\nLet's say you want to run the unit tests on all versions starting from the minimum defined in your `composer.json` file\nuntil the latest released one, you need to run the version lookup as a separate job:\n\n```yaml\nname: Testing matrix\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  php-versions:\n    name: Lookup PHP versions\n    runs-on: ubuntu-latest\n    outputs:\n      matrix: ${{ steps.versions.outputs.matrix }}\n    steps:\n      - uses: actions/checkout@v5\n      - uses: antfroger/php-version-action@v1\n        id: versions\n        with:\n          unstable: true # set to false (or remove the param) to exclude unreleased versions\n          unsupported: false # set to true (or remove the param) to include unsupported versions\n\n  test:\n    name: Test PHP ${{ matrix.php-version }} on ${{ matrix.os }}\n    runs-on: ${{ matrix.os }}\n    needs: php-versions\n\n    strategy:\n      matrix:\n        os: [ubuntu-latest] # add more os\n        php-version: ${{ fromJSON(needs.php-versions.outputs.matrix) }}\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v5\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php-version }}\n          coverage: xdebug\n          tools: composer:v2\n\n      - name: Test\n        run: echo \"run your tests\"\n```\n\n![Test with matrix](doc/test-matrix.png)\n\n### Custom Working Directory\n\nIf your `composer.json` is in a subdirectory:\n\n```yaml\n- name: Get PHP Versions\n  id: php-versions\n  uses: antfroger/php-version-action@v1\n  with:\n    working-directory: ./packages/my-package\n```\n\n### Include unstable versions\n\nBy default, unstable versions are not included. But if you want to include them, set the input `unstable` to `true`:\n\n```yaml\n- name: Get PHP Versions\n  id: php-versions\n  uses: antfroger/php-version-action@v1\n  with:\n    unstable: true\n```\n\n### Exclude unsupported versions\n\nBy default, unsupported versions (EOL and no security updates) are included. To exclude them, set `unsupported` to\n`false`:\n\n```yaml\n- name: Get PHP Versions\n  id: php-versions\n  uses: antfroger/php-version-action@v1\n  with:\n    unsupported: false\n```\n\n## Supported Version Constraints\n\nThe action supports all the constraints supported by\n[Composer](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints)\n\n## Summary\n\nThe action writes a\n[GitHub Actions Job Summary](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/) with\noutput values it identified.\n\n![Job summary](doc/job-summary.png)\n\n---\n\n_PHP Version Action is inspired by [Go version action](https://github.com/arnested/go-version-action/tree/main)_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfroger%2Fphp-version-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantfroger%2Fphp-version-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfroger%2Fphp-version-action/lists"}