> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/shivammathur/setup-php/llms.txt
> Use this file to discover all available pages before exploring further.

# Outputs

> Access setup-php output values in subsequent workflow steps using a step id.

`setup-php` exposes output values you can reference in later steps of your workflow. To access outputs, assign an `id` to the `setup-php` step and reference it using the `steps.<id>.outputs.<name>` expression.

```yaml theme={null}
- name: Setup PHP
  id: setup-php
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'

- name: Use PHP version output
  run: echo "PHP version is ${{ steps.setup-php.outputs.php-version }}"
```

***

<ResponseField name="php-version" type="string" required>
  The PHP version that was set up, in [semver](https://semver.org/) format (e.g. `8.5.4`).

  This is useful when you specify a non-exact version like `latest`, `8.x`, or `highest` and need to know the exact version that was installed — for example, to use it as a cache key or to log it in your workflow summary.
</ResponseField>

***

## Example: capturing and printing the PHP version

```yaml theme={null}
steps:
  - name: Setup PHP
    id: setup-php
    uses: shivammathur/setup-php@v2
    with:
      php-version: '8.5'

  - name: Print PHP version
    run: echo ${{ steps.setup-php.outputs.php-version }}
```

## Example: using the version as a cache key

```yaml theme={null}
steps:
  - name: Setup PHP
    id: setup-php
    uses: shivammathur/setup-php@v2
    with:
      php-version: 'latest'
      extensions: imagick, redis

  - name: Cache extensions
    uses: actions/cache@v4
    with:
      path: ~/.php-extensions
      key: php-${{ steps.setup-php.outputs.php-version }}-extensions
```
