https://github.com/typisttech/php-matrix-action
Generate PHP version matrix according to `composer.json`
https://github.com/typisttech/php-matrix-action
ci github-actions php
Last synced: about 1 month ago
JSON representation
Generate PHP version matrix according to `composer.json`
- Host: GitHub
- URL: https://github.com/typisttech/php-matrix-action
- Owner: typisttech
- License: mit
- Created: 2024-12-19T14:39:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-05-23T23:02:55.000Z (about 1 month ago)
- Last Synced: 2026-05-24T00:06:05.061Z (about 1 month ago)
- Topics: ci, github-actions, php
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Matrix Action
[](https://github.com/typisttech/php-matrix-action/releases/latest)
[](https://github.com/marketplace/actions/php-matrix)
[](https://github.com/typisttech/php-matrix-action/actions/workflows/test.yml)
[](https://github.com/typisttech/php-matrix-action/blob/master/LICENSE)
[](https://x.com/tangrufus)
[](https://bsky.app/profile/tangrufus.com)
[](https://github.com/sponsors/tangrufus)
[](https://typist.tech/contact/)
Generate PHP version matrix according to composer.json
Built with ♥ by Typist Tech
---
> [!TIP]
> **Hire Tang Rufus!**
>
> I am looking for my next role, freelance or full-time.
> If you find this tool useful, I can build you more dev tools like this.
> Let's talk if you are hiring PHP / Ruby / Go developers.
>
> Contact me at https://typist.tech/contact/
---
## Usage
See [action.yml](action.yml) and the underlying script [`typisttech/php-matrix`](https://github.com/typisttech/php-matrix/#options).
```yaml
- uses: typisttech/php-matrix-action@ee26ae37ffb37246b9a3912b71d95b661ad341b8 # v2.0.8
with:
# Path to composer.json
#
# Default: composer.json
composer-json: some/path/to/composer.json
# Version format.
#
# Available modes:
# - `minor-only`: Report `MAJOR.MINOR` versions only
# - `full`: Report all satisfying versions in `MAJOR.MINOR.PATCH` format
#
# Default: minor-only
mode: full
# Source of releases information.
#
# Available sources:
# - `auto`: Use `offline` in `minor-only` mode. Otherwise, fetch from [php.net]
# - `php.net`: Fetch releases information from [php.net]
# - `offline`: Use [hardcoded releases] information
#
# [php.net]: https://www.php.net/releases/index.php
# [hardcoded releases]: https://github.com/typisttech/php-matrix/blob/main/resources/all-versions.json
#
# Default: auto
source: offline
# PHP Matrix version.
#
# The version of [php-matrix] to use. Leave blank for latest. For example: v1.0.2
#
# [php-matrix]: https://github.com/typisttech/php-matrix
#
# Default: ''
version: v1.0.2
# Verify Attestation
#
# Whether to verify PHP matrix tarball attestation.
# Github Token
#
# GitHub token to use for authentication
#
# Default: ${{ github.token }}
github-token: ${{ secrets.GITHUB_PAT_TOKEN }}
```
### Outputs
| Key | Description | Example |
| --- | --- | --- |
| `constraint` | PHP constraint found in `composer.json` | `^7.3 \|\| ^8.0` |
| `versions` | String of an array of all supported PHP versions | In `minor-only` mode, `["7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]`
In `full` mode, `["7.4.998", "7.4.999", "8.4.998", "8.4.999"]` |
| `lowest` | Lowest supported PHP versions | In `minor-only` mode, `7.3`
In `full` mode, `7.3.0` |
| `highest` | Highest supported PHP versions | In `minor-only` mode, `8.4`
In `full` mode, `8.4.2` |
> [!TIP]
> **Hire Tang Rufus!**
>
> There is no need to understand any of these quirks.
> Let me handle them for you.
> I am seeking my next job, freelance or full-time.
>
> If you are hiring PHP / Ruby / Go developers,
> contact me at https://typist.tech/contact/
## Examples
Run tests against all supported PHP versions.
```yaml
name: Test
on:
push:
jobs:
php-matrix:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.php-matrix.outputs.versions }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: composer.json
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: typisttech/php-matrix-action@ee26ae37ffb37246b9a3912b71d95b661ad341b8 # v2.0.8
id: php-matrix
test:
runs-on: ubuntu-latest
needs: php-matrix
strategy:
matrix:
php-version: ${{ fromJSON(needs.php-matrix.outputs.versions) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # master
with:
php-version: ${{ matrix.php-version }}
- run: composer install
- run: composer test
```
Run tests on the highest supported PHP version only.
```yaml
name: Test
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: typisttech/php-matrix-action@ee26ae37ffb37246b9a3912b71d95b661ad341b8 # v2.0.8
id: php-matrix
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # master
with:
php-version: ${{ steps.php-matrix.outputs.highest }}
- run: composer install
- run: composer test
```
Run `$ composer audit` against all supported PHP versions.
```yaml
name: Composer Audit
on:
push:
jobs:
php-matrix:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.php-matrix.outputs.versions }}
highest: ${{ steps.php-matrix.outputs.highest }}
lowest: ${{ steps.php-matrix.outputs.lowest }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: composer.json
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: typisttech/php-matrix-action@ee26ae37ffb37246b9a3912b71d95b661ad341b8 # v2.0.8
id: php-matrix
composer-audit:
needs: php-matrix
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ${{ fromJSON(needs.php-matrix.outputs.versions) }}
dependency-versions: [highest]
include:
- php-version: ${{ needs.php-matrix.outputs.lowest }}
dependency-versions: lowest
- php-version: ${{ needs.php-matrix.outputs.highest }}
dependency-versions: locked
env:
COMPOSER_NO_AUDIT: 1
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: |
composer.json
composer.lock
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # master
with:
php-version: ${{ matrix.php-version }}
coverage: none
- uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
with:
dependency-versions: ${{ matrix.dependency-versions }}
- run: composer audit
```
## Credits
[`PHP Matrix Action`](https://github.com/typisttech/php-matrix-action) is a [Typist Tech](https://typist.tech) project and
maintained by [Tang Rufus](https://x.com/TangRufus), freelance developer [for hire](https://typist.tech/contact/).
Full list of contributors can be found [on GitHub](https://github.com/typisttech/php-matrix-action/graphs/contributors).
## Copyright and License
This project is a [free software](https://www.gnu.org/philosophy/free-sw.en.html) distributed under the terms of
the MIT license. For the full license, see [LICENSE](LICENSE).
## Contribute
Feedbacks / bug reports / pull requests are welcome.