Coder Social home page Coder Social logo

shivammathur / setup-php Goto Github PK

View Code? Open in Web Editor NEW
2.8K 30.0 327.0 25.21 MB

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

Home Page: https://setup-php.com

License: MIT License

Shell 35.07% PowerShell 20.93% TypeScript 42.37% JavaScript 0.10% PHP 1.53%
php github-actions php-extensions code-coverage tools continuous-integration composer static-analysis

setup-php's Introduction

Setup PHP in GitHub Actions

Setup PHP in GitHub Actions

GitHub Actions status Codecov Code Coverage LICENSE PHP Versions Supported

setup-php reddit setup-php twitter setup-php status

Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub Actions. This action gives you a cross-platform interface to set up the PHP environment you need to test your application. Refer to Usage section and examples to see how to use this.

Contents

โ˜๏ธ OS/Platform Support

Both GitHub-hosted and self-hosted runners are supported by setup-php on the following OS/Platforms.

GitHub-Hosted Runners

Virtual environment YAML workflow label Pre-installed PHP
Ubuntu 22.04 ubuntu-latest or ubuntu-22.04 PHP 8.1
Ubuntu 20.04 ubuntu-20.04 PHP 7.4 to PHP 8.3
Windows Server 2022 windows-latest or windows-2022 PHP 8.3
Windows Server 2019 windows-2019 PHP 8.3
macOS Sonoma 14.x macos-14 -
macOS Ventura 13.x macos-13 PHP 8.3
macOS Monterey 12.x macos-latest or macos-12 PHP 8.3

Self-Hosted Runners

Host OS/Virtual environment YAML workflow label
Ubuntu 22.04 self-hosted or Linux
Ubuntu 20.04 self-hosted or Linux
Debian 11 self-hosted or Linux
Debian 10 self-hosted or Linux
Windows 7 and newer self-hosted or Windows
Windows Server 2012 R2 and newer self-hosted or Windows
macOS Sonoma 14.x x86_64/arm64 self-hosted or macOS
macOS Ventura 13.x x86_64/arm64 self-hosted or macOS
macOS Monterey 12.x x86_64/arm64 self-hosted or macOS
  • Refer to the self-hosted setup to use the action on self-hosted runners.
  • Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
  • If the requested PHP version is pre-installed, setup-php switches to it, otherwise it installs the PHP version.

๐ŸŽ‰ PHP Support

On all supported OS/Platforms the following PHP versions can be set up as per the runner.

  • PHP 5.3 to PHP 8.4 on GitHub-hosted runners, except for macOS ARM64 runners (macos-14).
  • PHP 5.6 to PHP 8.4 on GitHub-hosted macOS ARM64 runners (macos-14).
  • PHP 5.6 to PHP 8.4 on self-hosted runners.
PHP Version Stability Release Support Runner Support
5.3 Stable End of life GitHub-hosted
5.4 Stable End of life GitHub-hosted
5.5 Stable End of life GitHub-hosted
5.6 Stable End of life GitHub-hosted, self-hosted
7.0 Stable End of life GitHub-hosted, self-hosted
7.1 Stable End of life GitHub-hosted, self-hosted
7.2 Stable End of life GitHub-hosted, self-hosted
7.3 Stable End of life GitHub-hosted, self-hosted
7.4 Stable End of life GitHub-hosted, self-hosted
8.0 Stable End of life GitHub-hosted, self-hosted
8.1 Stable Security fixes only GitHub-hosted, self-hosted
8.2 Stable Active GitHub-hosted, self-hosted
8.3 Stable Active GitHub-hosted, self-hosted
8.4 Nightly In development GitHub-hosted, self-hosted

Notes:

  • Specifying 8.4 in php-version input installs a nightly build of PHP 8.4.0-dev. See nightly build setup for more information.
  • To use JIT on PHP 8.0 and above, refer to the JIT configuration section.

โž• PHP Extension Support

PHP extensions can be set up using the extensions input. It accepts a string in csv-format.

  • On Ubuntu, extensions which are available as a package, available on PECL or a git repository can be set up.
- name: Setup PHP with PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: imagick, swoole
  • On Windows, extensions available on PECL which have the DLL binary can be set up.

  • On macOS, extensions available on PECL or a git repository can be set up.

  • On Ubuntu and macOS to compile and install an extension from a git repository follow this guide.

  • Extensions installed along with PHP if specified are enabled.

  • Specific versions of extensions available on PECL can be set up by suffixing the extension's name with the version. This is useful for installing old versions of extensions which support end of life PHP versions.

- name: Setup PHP with specific version of PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '5.4'
    extensions: swoole-1.9.3
  • Extensions with pre-release versions available on PECL can be set up by suffixing the extension's name with its state i.e alpha, beta, devel or snapshot.
- name: Setup PHP with pre-release PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: xdebug-beta
  • On Ubuntu and macOS to compile and install an extension from PECL with libraries or custom configuration follow this guide.

  • Shared extensions can be disabled by prefixing them with a :. All extensions depending on the specified extension will also be disabled.

- name: Setup PHP and disable opcache
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: :opcache
  • All shared extensions can be disabled by specifying none. When none is specified along with other extensions, it is hoisted to the start of the input. So, all the shared extensions will be disabled first, then rest of the extensions in the input will be processed.

Note: This disables all core and third-party shared extensions and thus, can break some tools which need them. Required extensions are enabled again when the tools are set up on a best-effort basis. So it is recommended to add the extensions required for your tools after none in the extensions input to avoid any issues.

- name: Setup PHP without any shared extensions except mbstring
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: none, mbstring
  • Extension intl can be set up with specific ICU version for PHP 5.6 and above in Ubuntu workflows by suffixing intl with the ICU version. ICU 50.2 and newer versions are supported. Refer to ICU builds for the specific versions supported.
- name: Setup PHP with intl
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: intl-70.1
  • Extensions loaded by default after setup-php runs can be found on the wiki.

  • These extensions have custom support:

    • cubrid and pdo_cubrid on Ubuntu.
    • event, gearman, geos and relay on Ubuntu and macOS.
    • blackfire, couchbase, ioncube, oci8, pdo_firebird, pdo_oci, pecl_http, phalcon3, phalcon4, phalcon5, and zephir_parser on all supported OS.
  • By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set fail-fast flag to true.

- name: Setup PHP with fail-fast
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: oci8
  env:
    fail-fast: true

๐Ÿ”ง Tools Support

These tools can be set up globally using the tools input. It accepts a string in csv-format.

behat, blackfire, blackfire-player, box, castor, churn, codeception, composer, composer-normalize, composer-prefetcher, composer-require-checker, composer-unused, cs2pr, deployer, ecs, flex, grpc_php_plugin, infection, parallel-lint, pecl, phan, phing, phinx, phive, php-config, php-cs-fixer, php-scoper, phpcbf, phpcpd, phpcs, phpdoc or phpDocumentor, phpize, phplint, phpmd, phpspec, phpstan, phpunit, phpunit-bridge, phpunit-polyfills, pint, prestissimo, protoc, psalm, rector, symfony or symfony-cli, vapor or vapor-cli, wp or wp-cli

- name: Setup PHP with tools
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: php-cs-fixer, phpunit
  • In addition to above tools any composer tool or package can also be set up globally by specifying it as vendor/package matching the listing on Packagist. This format accepts the same version constraints as composer.
- name: Setup PHP with tools
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: vimeo/psalm
  • To set up a particular version of a tool, specify it in the form tool:version.

    Version can be in the following format:

    • Semver. For example tool:1.2.3 or tool:1.2.3-beta1.
    • Major version. For example tool:1 or tool:1.x.
    • Major and minor version. For example tool:1.2 or tool:1.2.x.

    When you specify just the major version or the version in major.minor format, the latest patch version matching the input will be setup.

    With the exception of major versions of composer, if you specify only the major version or the version in major.minor format for a tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a GitHub OAuth token. You can do that by setting GITHUB_TOKEN environment variable. The COMPOSER_TOKEN environment variable has been deprecated in favor of GITHUB_TOKEN and will be removed in the next major version.

- name: Setup PHP with tools
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: php-cs-fixer:3.39, phpunit:10.4
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  • The latest stable version of composer is set up by default. You can set up the required composer version by specifying the major version v1 or v2, or the version in major.minor or semver format. Additionally, for composer snapshot and preview can also be specified to set up the respective releases.
- name: Setup PHP with composer v2
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: composer:v2
  • If you do not use composer in your workflow, you can specify tools: none to skip it.
- name: Setup PHP without composer
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: none
  • Tools pear, pecl, phpize and php-config are set up by default for all supported PHP versions on Linux and macOS.

  • The latest version of blackfire cli is set up when blackfire is specified in tools input. Please refer to the official documentation for using blackfire with GitHub Actions.

  • Tools prestissimo and composer-prefetcher will be skipped unless composer:v1 is also specified in tools input. It is recommended to drop prestissimo and use composer v2.

  • By default, except composer tools which cannot be set up gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set fail-fast flag to true.

- name: Setup PHP with fail-fast
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: deployer
  env:
    fail-fast: true

Notes

  • Input tools is useful to set up tools which are only used in CI workflows, thus keeping your composer.json tidy.
  • If you do not want to use all your dev-dependencies in workflow, you can run composer with --no-dev and install required tools using tools input to speed up your workflow.
  • By default, COMPOSER_NO_INTERACTION is set to 1 and COMPOSER_PROCESS_TIMEOUT is set to 0. In effect, this means that Composer commands in your scripts do not need to specify --no-interaction.
  • Also, COMPOSER_NO_AUDIT is set to 1. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a composer audit step before you install them.
  • If you want to set a different COMPOSER_PROCESS_TIMEOUT, you can set it in your workflow file using the env keyword.
- name: Setup PHP with composer and custom process timeout
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    COMPOSER_PROCESS_TIMEOUT: 300

๐Ÿ“ถ Coverage Support

Xdebug

Specify coverage: xdebug to use Xdebug and disable PCOV.
Runs on all PHP versions supported.

- name: Setup PHP with Xdebug
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    coverage: xdebug
  • When you specify coverage: xdebug, the latest version of Xdebug compatible with the PHP version is set up by default.
  • If you need Xdebug 2.x on PHP 7.2, 7.3 or 7.4, you can specify coverage: xdebug2.
- name: Setup PHP with Xdebug 2.x
  uses: shivammathur/setup-php@v2
  with:
    php-version: '7.4'
    coverage: xdebug2

Note: Xdebug is enabled by default on Ubuntu GitHub Actions images, so if you are not using it in your workflow it is recommended to disable it as that will have a positive impact on your PHP performance. Please refer to the disable coverage section for details.

PCOV

Specify coverage: pcov to use PCOV and disable Xdebug.
Runs on PHP 7.1 and newer PHP versions.

  • If your source code directory is other than src, lib or, app, specify pcov.directory using the ini-values input.
- name: Setup PHP with PCOV
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    ini-values: pcov.directory=api #optional, see above for usage.
    coverage: pcov
  • PHPUnit 8.x and above supports PCOV out of the box.
  • If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up pcov/clobber before executing your tests.
- name: Setup PCOV
  run: |
    composer require pcov/clobber
    vendor/bin/pcov clobber

Disable Coverage

Specify coverage: none to disable both Xdebug and PCOV.

Disable coverage for these reasons:

  • You are not generating coverage reports while testing.
  • You are using phpdbg for running your tests.
  • You are profiling your code using blackfire.
  • You are using PHP in JIT mode. Please refer to JIT configuration section for more details.
- name: Setup PHP with no coverage driver
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    coverage: none

๐Ÿ“ Usage

Inputs

Specify using with keyword

php-version (optional)

  • Specify the PHP version you want to set up.
  • Accepts a string. For example '8.3'.
  • Accepts lowest to set up the lowest supported PHP version.
  • Accepts highest or latest to set up the latest stable PHP version.
  • Accepts nightly to set up a nightly build from the master branch of PHP.
  • Accepts the format d.x, where d is the major version. For example 5.x, 7.x and 8.x.
  • See PHP support for the supported PHP versions.
  • If not specified, it looks for the following in order:
    • The php-version-file input if it exists
    • A composer.lock file and the platform-overrides.php value
    • A composer.json file and the config.platform.php value

php-version-file (optional)

  • Specify a file with the PHP version you want to set up.
  • Accepts a string. For example '.phpenv-version'.
  • See PHP support for the supported PHP versions.
  • By default, .php-version file is used.
  • If not specified and the default .php-version file is not found, the latest stable PHP version is set up.

extensions (optional)

  • Specify the extensions you want to add or disable.
  • Accepts a string in csv-format. For example mbstring, :opcache.
  • Accepts none to disable all shared extensions.
  • Shared extensions prefixed with : are disabled.
  • See PHP extension support for more info.

ini-file (optional)

  • Specify the base php.ini file.
  • Accepts production, development or none.
  • By default, production php.ini file is used.

ini-values (optional)

  • Specify the values you want to add to php.ini.
  • Accepts a string in csv-format. For example post_max_size=256M, max_execution_time=180.
  • Accepts ini values with commas if wrapped in quotes. For example xdebug.mode="develop,coverage".

coverage (optional)

  • Specify the code-coverage driver you want to set up.
  • Accepts xdebug, pcov or none.
  • See coverage support for more info.

tools (optional)

  • Specify the tools you want to set up.
  • Accepts a string in csv-format. For example: phpunit, phpcs
  • See tools support for tools supported.

Outputs

php-version

On GitHub Actions you can assign the setup-php step an id, you can use the same to get the outputs in a later step.

  • Provides the PHP version in semver format.
- name: Setup PHP
  id: setup-php
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'

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

Flags

Specify using env keyword

fail-fast (optional)

  • Specify to mark the workflow as failed if an extension or tool fails to set up.
  • This changes the default mode from graceful warnings to fail-fast.
  • By default, it is set to false.
  • Accepts true and false.

phpts (optional)

  • Specify to set up a thread-safe build of PHP.
  • Accepts nts for non-thread-safe and zts or ts for thread-safe.
  • By default, it is set to nts.
  • See thread safe setup for more info.

update (optional)

  • Specify to update PHP on the runner to the latest patch version.
  • Accepts true and false.
  • By default, it is set to false.
  • See force update setup for more info.

See below for more info.

Basic Setup

Set up a particular PHP version.

steps:
- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    extensions: mbstring, intl
    ini-values: post_max_size=256M, max_execution_time=180
    coverage: xdebug
    tools: php-cs-fixer, phpunit

Matrix Setup

Set up multiple PHP versions on multiple operating systems.

jobs:
  run:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
        php-versions: ['8.1', '8.2', '8.3']
        phpunit-versions: ['latest']
        include:
          - operating-system: 'ubuntu-latest'
            php-versions: '8.0'
            phpunit-versions: 9
    steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: mbstring, intl
        ini-values: post_max_size=256M, max_execution_time=180
        coverage: xdebug
        tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Nightly Build Setup

Set up a nightly build of PHP 8.4.

  • These PHP versions are currently in active development and might contain bugs and breaking changes.
  • Some user space extensions might not support this version currently.
steps:
- name: Setup nightly PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.4'
    extensions: mbstring
    ini-values: post_max_size=256M, max_execution_time=180
    coverage: xdebug
    tools: php-cs-fixer, phpunit

Debug Build Setup

Set up a PHP build with debugging symbols.

  • Production release builds of PHP without debugging symbols are set up by default.
  • You can use the debug environment variable to set up a build with debugging symbols for PHP 5.6 and above.

Notes

  • On Linux, the debug symbols are added as debug info files in the /usr/lib/debug/.build-id directory. These files match the build-id in the ELF section of the PHP binaries and debugging tools like gdb are able to resolve the symbols from these files.
  • On Windows, the debug symbols are added as pdb files in the PHP installation directory.
  • On macOS, the debug symbols are compiled into the binaries.
steps:
- name: Setup PHP with debugging symbols
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    debug: true # specify true or false

Thread Safe Setup

Set up TS or NTS PHP.

  • NTS versions are set up by default.
jobs:
  run:
    runs-on: [ubuntu-latest, windows-latest, macos-latest]
    name: Setup PHP TS
    steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.3'
      env:
        phpts: ts # specify ts or nts

Force Update Setup

Update to the latest patch of PHP versions.

  • Pre-installed PHP versions are not updated to their latest patch release by default.
  • If ppa:ondrej/php is missing on the Ubuntu GitHub environment, the PHP version is updated to the latest patch release.
  • You can specify the update environment variable to true for updating to the latest release.
- name: Setup PHP with latest versions
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    update: true # specify true or false

Verbose Setup

Debug your workflow

To debug any issues, you can use the verbose tag instead of v2.

- name: Setup PHP with logs
  uses: shivammathur/setup-php@verbose
  with:
    php-version: '8.3'

Multi-Arch Setup

Set up PHP on multiple architecture on Ubuntu GitHub Runners.

  • PHP 5.6 to PHP 8.3 are supported by setup-php on multiple architecture on Ubuntu.
  • For this, you can use shivammathur/node images as containers. These have compatible Nodejs installed for setup-php.
  • Currently, for ARM based setup, you will need self-hosted runners.
jobs:
  run:
    runs-on: ubuntu-latest
    container: shivammathur/node:latest-${{ matrix.arch }}
    strategy:
      matrix:
        arch: ["amd64", "i386"]
    steps:
      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'

Self Hosted Setup

Set up PHP on a self-hosted runner.

  • To set up a containerised self-hosted runner, refer to the following guides as per your base operating system.

  • To set up the runner directly on the host OS or in a virtual machine, follow this requirements guide before setting up the self-hosted runner.

  • If your workflow uses service containers, then set up the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.

It is recommended to specify the environment variable runner with the value self-hosted for self-hosted environments.

jobs:
  run:
    runs-on: self-hosted
    strategy:
      matrix:
        php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
    name: PHP ${{ matrix.php-versions }}
    steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
      env:
        runner: self-hosted

Notes

  • Do not set up multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
  • Do not set up self-hosted runners on the side on your development environment or your production server.
  • Avoid using the same labels for your self-hosted runners which are used by GitHub-hosted runners.

Local Testing Setup

Test your Ubuntu workflow locally using nektos/act.

jobs:
  run:
    runs-on: ubuntu-latest
    steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.3'

Run the workflow locally with act using shivammathur/node docker images.

Choose the image tag which matches the runs-on property in your workflow. For example, if you are using ubuntu-20.04 in your workflow, run act -P ubuntu-20.04=shivammathur/node:2004.

# For runs-on: ubuntu-latest
act -P ubuntu-latest=shivammathur/node:latest

# For runs-on: ubuntu-22.04
act -P ubuntu-22.04=shivammathur/node:2204

# For runs-on: ubuntu-20.04
act -P ubuntu-20.04=shivammathur/node:2004

JIT Configuration

Enable Just-in-time (JIT) on PHP 8.0 and above.

  • To enable JIT, enable opcache in cli mode by setting opcache.enable_cli=1.
  • JIT conflicts with Xdebug, PCOV, and other extensions which override zend_execute_ex function, so set coverage: none and disable any such extension if added.
  • By default, opcache.jit=1235 and opcache.jit_buffer_size=256M are set which can be changed using ini-values input.
  • For detailed information about JIT related directives refer to the official PHP documentation.

For example to enable JIT in tracing mode with buffer size of 64 MB.

- name: Setup PHP with JIT in tracing mode
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    coverage: none
    ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M

Cache Extensions

You can cache PHP extensions using shivammathur/cache-extensions and action/cache GitHub Actions. Extensions which take very long to set up when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
Refer to shivammathur/cache-extensions for details.

Cache Composer Dependencies

If your project uses composer, you can persist the composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.

- name: Get composer cache directory
  id: composer-cache
  run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
  uses: actions/cache@v4
  with:
    path: ${{ steps.composer-cache.outputs.dir }}
    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
    restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
  run: composer install --prefer-dist

Notes

  • Please do not cache vendor directory using action/cache as that will have side effects.
  • If you do not commit composer.lock, you can use the hash of composer.json as the key for your cache.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
  • If you support a range of composer dependencies and use prefer-lowest and prefer-stable options, you can store them in your matrix and add them to the keys.
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-

GitHub Composer Authentication

If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in major.minor format, you can hit the rate limit. To avoid this you can specify an OAuth token by setting GITHUB_TOKEN environment variable. You can use GITHUB_TOKEN secret for this purpose.

The COMPOSER_TOKEN environment variable has been deprecated in favor of GITHUB_TOKEN and will be removed in the next major version.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Private Packagist Authentication

If you use Private Packagist for your private composer dependencies, you can set the PACKAGIST_TOKEN environment variable to authenticate.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}

Manual Composer Authentication

In addition to GitHub or Private Packagist, if you want to authenticate private repositories hosted elsewhere, you can set the COMPOSER_AUTH_JSON environment variable with the authentication methods and the credentials in json format. Please refer to the authentication section in composer documentation for more details.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
  env:
    COMPOSER_AUTH_JSON: |
      {
        "http-basic": {
          "example.org": {
            "username": "${{ secrets.EXAMPLE_ORG_USERNAME }}",
            "password": "${{ secrets.EXAMPLE_ORG_PASSWORD }}"
          }
        }
      }

Inline PHP Scripts

If you have to run multiple lines of PHP code in your workflow, you can do that easily without saving it to a file.

Put the code in the run property of a step and specify the shell as php {0}.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'

- name: Run PHP code
  shell: php {0}
  run: |
    <?php
    $welcome = "Hello, world";
    echo $welcome;

Problem Matchers

Problem matchers are json configurations which identify errors and warnings in your logs and surface them prominently in the GitHub Actions UI by highlighting them and creating code annotations.

PHP

Setup problem matchers for your PHP output by adding this step after the setup-php step.

- name: Setup problem matchers for PHP
  run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

PHPUnit

Setup problem matchers for your PHPUnit output by adding this step after the setup-php step.

- name: Setup problem matchers for PHPUnit
  run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

PHPStan

PHPStan supports error reporting in GitHub Actions, so it does not require problem matchers.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: phpstan

- name: Run PHPStan
  run: phpstan analyse src

Psalm

Psalm supports error reporting in GitHub Actions with an output format github.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: psalm

- name: Run Psalm
  run: psalm --output-format=github

Tools with checkstyle support

For tools that support checkstyle reporting like phpstan, psalm, php-cs-fixer and phpcs you can use cs2pr to annotate your code.
For examples refer to the cs2pr documentation.

Here is an example with phpcs.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.3'
    tools: cs2pr, phpcs

- name: Run phpcs
  run: phpcs -q --report=checkstyle src | cs2pr

Examples

Examples of using setup-php with various PHP frameworks and packages.

Framework/Package Runs on Workflow
Blackfire macOS, ubuntu and windows blackfire.yml
Blackfire Player macOS, ubuntu and windows blackfire-player.yml
CakePHP with MySQL and Redis ubuntu cakephp-mysql.yml
CakePHP with PostgreSQL and Redis ubuntu cakephp-postgres.yml
CakePHP without services macOS, ubuntu and windows cakephp.yml
CodeIgniter macOS, ubuntu and windows codeigniter.yml
Laminas MVC macOS, ubuntu and windows laminas-mvc.yml
Laravel with MySQL and Redis ubuntu laravel-mysql.yml
Laravel with PostgreSQL and Redis ubuntu laravel-postgres.yml
Laravel without services macOS, ubuntu and windows laravel.yml
Lumen with MySQL and Redis ubuntu lumen-mysql.yml
Lumen with PostgreSQL and Redis ubuntu lumen-postgres.yml
Lumen without services macOS, ubuntu and windows lumen.yml
Phalcon with MySQL ubuntu phalcon-mysql.yml
Phalcon with PostgreSQL ubuntu phalcon-postgres.yml
Roots/bedrock ubuntu bedrock.yml
Roots/sage ubuntu sage.yml
Slim Framework macOS, ubuntu and windows slim-framework.yml
Symfony with MySQL ubuntu symfony-mysql.yml
Symfony with PostgreSQL ubuntu symfony-postgres.yml
Symfony without services macOS, ubuntu and windows symfony.yml
Yii2 Starter Kit with MySQL ubuntu yii2-mysql.yml
Yii2 Starter Kit with PostgreSQL ubuntu yii2-postgres.yml

๐Ÿ”– Versioning

  • Use the v2 tag as setup-php version. It is a rolling tag and is synced with the latest minor and patch releases. With v2 you automatically get the bug fixes, security patches, new features and support for latest PHP releases.
  • Semantic release versions can also be used. It is recommended to use dependabot with semantic versioning to keep the actions in your workflows up to date.
  • Commit SHA can also be used, but are not recommended unless you set up tooling to update them with each release of the action.
  • A new major version of the action will only be tagged when there are breaking changes in the setup-php API i.e. inputs, outputs, and environment flags.
  • For debugging any issues verbose tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
  • It is highly discouraged to use the main branch as version, it might break your workflow after major releases as they have breaking changes.
  • If you are using the v1 tag or a 1.x.y version, you should switch to v2 as v1 is not supported anymore.

๐Ÿ“œ License

  • The scripts and documentation in this project are under the MIT License.
  • This project has multiple dependencies. Their licenses can be found in their respective repositories.
  • The logo for setup-php is a derivative work of php.net logo and is licensed under the CC BY-SA 4.0 License.

๐Ÿ‘ Contributions

Contributions are welcome!

  • See Contributor's Guide before you start.
  • If you face any issues or want to suggest a feature/improvement, start a discussion here.

Contributors of setup-php and other related projects

Contributors of setup-php and related projects

๐Ÿ’– Support This Project

  • Please star the project and share it. If you blog, please share your experience of using setup-php.
  • Please reach out if you have any questions about sponsoring setup-php.

Many users and organisations support setup-php via GitHub Sponsors.

Sponsor shivammathur

These companies generously provide setup-php their products and services to aid in the development of this project.

JetBrains ย ย ย ย ย ย ย ย ย  Mac Stadium Mac Stadium ย ย ย ย ย ย ย ย ย  Tidelift

๐Ÿ“ฆ Dependencies

๐Ÿ“‘ Further Reading

setup-php's People

Contributors

alcaeus avatar amnuts avatar aneeshrelan avatar d8vjork avatar davereid avatar dependabot-preview[bot] avatar dependabot[bot] avatar em411 avatar fortkle avatar grahamcampbell avatar jaapio avatar jasongill avatar jrfnl avatar localheinz avatar lolautruche avatar markseuffert avatar mfn avatar mlocati avatar nanasess avatar nathannaveen avatar naveensrinivasan avatar rotzbua avatar ruudboon avatar shivammathur avatar stevelacey avatar svenluijten avatar szepeviktor avatar theofidry avatar viktorruskai avatar zaherg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

setup-php's Issues

INTL php extension take very long time to install

Hello,

When I run setup-php action with INTL extension, it take +1 minute more than without.
The total duration is 1m41s, which is really slow.

image

Without INTL the step duration is OK.

Do you have any idea to resolve this problem? It looks like other extensions I use are already installed?

Never ending setup Setup PHP action

It seems for the following configuration I get infinity loop or something like that :)

      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.1'
          extensions: psr zip
          tools: pecl

image

Unable to install PSR extension using PHP 7.4

      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: ${{ matrix.php }}
          extensions: gmp, pdo_sqlite, psr, zip
          tools: phpize, php-config
          coverage: xdebug
          ini-values: variables_order=EGPCS, enable_dl=On, allow_url_fopen=On, error_reporting=-1, memory_limit=1G, date.timezone=UTC, xdebug.max_nesting_level=256

      - name: Minimal Load Test for Required Extensions
        run: |
          for e in gmp pdo_sqlite psr zip; do
            php --ri $e 1>/dev/null || (echo "Extension $e was not found")
          done

The output for PHP 7.4 is:

Extension psr was not found

PHP 7.0, 7.1, 7.2, 7.3 works as expected. A day ago (before 1.7.3 release) all was ok.

Unclear coverage options

There are 3 options for coverage:

  • xdebug
  • pcov
  • none
  1. What's the default? Seem's like xdebug is by default on when nothing is specified, is that correct behaviour? I'd not expect to have xdebug enabled by default.
  2. Considering xdebug is not default it could then be reduced only to xdebug and pcov, none would be redundant.
  3. What are the versions of xdebug nad pcov used by this action?

uopz extension is not loaded after setup

Hey, here is the log which shows that uopz is installed and enabled.

Run shivammathur/setup-php@master
  with:
    php-version: 7.1
    extension-csv: redis, uopz
sh /opt/hostedtoolcache/linux.sh 7.1 /home/runner/work/_actions/shivammathur/setup-php/master/lib

==> Setup PHP and Composer
โœ“ PHP Switched to PHP7.1
โœ“ Composer Installed

==> Setup Extensions
โœ“ redis Enabled
โœ“ uopz Installed and enabled

but composer complains that the extension is not installed

Problem 1
    - Installation request for duncan3dc/uopz-expectations ^0.3.0 -> satisfiable by duncan3dc/uopz-expectations[0.3.0].
    - duncan3dc/uopz-expectations 0.3.0 requires ext-uopz * -> the requested PHP extension uopz is missing from your system.

any advise on how to solve this?

narrowspark/automatic-composer-prefetcher as a alternative to prestissimo

Is your feature request related to a problem? Please describe.
I want to provide a more feature richt alternative to prestissimo
unlike hirak/prestissimo, it doesn't require the curl extension and has zero extra dependencies. Instead, it reuses the existing code infrastructure in Composer to download packages.

And it has support for skipping legacy package tags, to reduce the resolve time on package finding in composer.

Describe the solution you'd like
adding automatic-composer-prefetcher to the tools options

Describe alternatives you've considered
n/a

Additional context
https://github.com/narrowspark/automatic-composer-prefetcher

The process 'pwsh' failed with exit code 1

Describe the bug

Installation on Windows fails since today with the following error message: The checksum of the downloaded CA certificates is wrong!

To reproduce

on: push

jobs:
    main:
        runs-on: windows-latest
        steps:
            - name: Setup PHP
              uses: shivammathur/setup-php@master
              with:
                  php-version: 7.3
                  extension-csv: dom, filter, gd, hash, intl, json, pcre, pdo, zlib
                  coverage: none

Log

Run shivammathur/setup-php@master
pwsh C:\hostedtoolcache\windows\win32.ps1 -version 7.3 -dir d:\a\_actions\shivammathur\setup-php\master\dist

==> Setup PhpManager 
โˆš PhpManager Installed 

==> Setup PHP and Composer 
The checksum of the downloaded CA certificates is wrong!
At C:\Users\runneradmin\Documents\PowerShell\Modules\PhpManager\1.19.2.231\private\Get-CACertFromCurl.ps1:35 char:13
+             throw "The checksum of the downloaded CA certificates is  ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (The checksum of the\u2026tificates is wrong!:String) [], RuntimeException
+ FullyQualifiedErrorId : The checksum of the downloaded CA certificates is wrong!

##[error]The process 'pwsh' failed with exit code 1
##[error]Node run failed with exit code 1

Additional information

https://github.com/leofeyer/gha-test/commit/b9c59a05a74bf5bc1632b69eb87891094054d187/checks?check_suite_id=331319247

Documentation on using composer with private repositories

Is your feature request related to a problem? Please describe.
It would be nice to see an example where private composer packages are used

Describe the solution you'd like
Some way to pass GITHUB_TOKEN without creating a COMPOSER_AUTH secret for every repository where an action is used

Describe alternatives you've considered
Ive tried to use composer config before doing composer install:

run: |
    composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
    composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

Ive also tried to concatinate COMPOSER_AUTH and pass it in env:

env:
    COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}" }}'

Additional context
n/a

pdo_mysql and pdo_sqlite should install when specified in extension-csv input

I have the following step in my workflow:

- name: Install PHP
  uses: shivammathur/[email protected]
  with:
    php-version: 7.0
    extension-csv: pdo, pdo_sqlite, pdo_mysql

When the workflow is run, the steps outputs the following:

==> Setup PHP and Composer
โœ“ PHP Installed PHP7.0
โœ“ Composer Installed

==> Setup Extensions
โœ“ pdo Enabled
โœ— pdo_sqlite Could not find php7.0-pdo_sqlite
โœ— pdo_mysql Could not find php7.0-pdo_mysql

And the extensions are not installed and therefore Composer emits an error on the next step. This is a bug because pdo_sqlite and pdo_mysql exist, work in PHP 7.1โ€“7.3 and are installed on my machine with PHP 7.0.

Failed to install extensions in php version < 7.1

To begin: Thanks for this great action.

It seems it has a little bug. When I try to install e.g. mbstring on php 5.6:
image

And then check below with php -m:
image

As you can see there is no curl and no mbstring.

Full install log:

Run shivammathur/setup-php@master
  with:
    php-version: 5.6
    extension-csv: curl, mbstring
Version: 5.6
Extensions: curl, mbstring
sudo chmod a+x 5.6linux.sh
The file was saved!
./5.6linux.sh 5.6
Get:1 https://download.mono-project.com/repo/ubuntu stable-bionic InRelease [5143 B]
Get:2 https://packages.microsoft.com/repos/azure-cli bionic InRelease [3188 B]
Get:3 https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic InRelease [3226 B]
Ign:4 http://dl.google.com/linux/chrome/deb stable InRelease
Get:5 https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease [3226 B]
Get:6 http://packages.cloud.google.com/apt cloud-sdk InRelease [6337 B]
Hit:7 https://dl.yarnpkg.com/debian stable InRelease
Hit:8 http://azure.archive.ubuntu.com/ubuntu bionic InRelease
Get:9 http://azure.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:10 http://azure.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:11 http://dl.google.com/linux/chrome/deb stable Release [943 B]
Get:12 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease [15.9 kB]
Get:13 https://cli-assets.heroku.com/apt ./ InRelease [2533 B]
Get:15 http://dl.google.com/linux/chrome/deb stable Release.gpg [819 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:14 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [8993 B]
Hit:18 http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic InRelease
Get:19 https://download.mono-project.com/repo/ubuntu stable-bionic/main amd64 Packages [48.9 kB]
Get:20 https://packages.microsoft.com/repos/azure-cli bionic/main amd64 Packages [6798 B]
Hit:21 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic InRelease
Hit:17 https://packagecloud.io/github/git-lfs/ubuntu bionic InRelease
Get:22 https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic/main amd64 Packages [71.8 kB]
Get:23 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
Get:24 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 Packages [99.5 kB]
Get:25 http://packages.cloud.google.com/apt cloud-sdk/main amd64 Packages [86.7 kB]
Hit:26 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic InRelease
Get:27 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [739 kB]
Get:28 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [266 kB]
Get:29 http://azure.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [14.5 kB]
Get:30 http://azure.archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [4736 B]
Get:31 http://azure.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1006 kB]
Get:32 http://azure.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [309 kB]
Get:33 http://azure.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [7528 B]
Get:34 http://azure.archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [3868 B]
Get:35 http://azure.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4020 B]
Get:36 https://cli-assets.heroku.com/apt ./ Packages [612 B]
Get:37 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1104 B]
Get:38 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 Packages [29.7 kB]
Get:39 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic/main amd64 Packages [528 B]
Get:40 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [516 kB]
Get:41 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages [51.7 kB]
Get:42 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [173 kB]
Get:43 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main Translation-en [24.3 kB]
Get:44 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [7648 B]
Get:45 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [3064 B]
Get:46 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [607 kB]
Get:47 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [202 kB]
Get:48 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4904 B]
Get:49 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2396 B]
Fetched 4615 kB in 5s (966 kB/s)
Reading package lists...

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Hit:1 http://azure.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://azure.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://azure.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 https://download.mono-project.com/repo/ubuntu stable-bionic InRelease
Ign:5 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:6 https://packages.microsoft.com/repos/azure-cli bionic InRelease
Hit:7 http://packages.cloud.google.com/apt cloud-sdk InRelease
Hit:9 https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic InRelease
Hit:11 https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease
Hit:12 https://dl.yarnpkg.com/debian stable InRelease
Hit:10 https://cli-assets.heroku.com/apt ./ InRelease
Hit:13 http://dl.google.com/linux/chrome/deb stable Release
Hit:8 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Hit:14 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:15 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease
Hit:17 http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic InRelease
Hit:16 https://packagecloud.io/github/git-lfs/ubuntu bionic InRelease
Hit:18 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic InRelease
Hit:19 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Hit:20 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic InRelease
Reading package lists...
Building dependency tree...
Reading state information...
386 packages can be upgraded. Run 'apt list --upgradable' to see them.

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  bc dns-root-data dnsmasq-base ebtables landscape-common liblxc-common
  liblxc1 libuv1 lxcfs lxd lxd-client python3-attr python3-automat
  python3-click python3-colorama python3-constantly python3-hyperlink
  python3-incremental python3-pam python3-pyasn1 python3-pyasn1-modules
  python3-service-identity python3-twisted python3-twisted-bin
  python3-zope.interface uidmap xdelta3
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4 php5.6-cli php5.6-common
  php5.6-json php5.6-opcache php5.6-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
  openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6
  libaprutil1-dbd-sqlite3 libaprutil1-ldap php5.6 php5.6-cli php5.6-common
  php5.6-json php5.6-opcache php5.6-readline ssl-cert
The following packages will be upgraded:
  curl libcurl4
2 upgraded, 14 newly installed, 0 to remove and 384 not upgraded.
Need to get 7493 kB of archives.
After this operation, 22.1 MB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-2 [10.6 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-ldap amd64 1.6.1-2 [8764 B]
Get:3 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-bin amd64 2.4.29-1ubuntu4.11 [1071 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-utils amd64 2.4.29-1ubuntu4.11 [83.9 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-data all 2.4.29-1ubuntu4.11 [160 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2 amd64 2.4.29-1ubuntu4.11 [95.1 kB]
Get:7 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.8 [159 kB]
Get:8 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.8 [214 kB]
Get:9 http://azure.archive.ubuntu.com/ubuntu bionic/main amd64 ssl-cert all 1.0.39 [17.0 kB]
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6-common amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [2762 kB]
Get:11 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6-json amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [17.9 kB]
Get:12 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6-opcache amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [62.8 kB]
Get:13 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6-readline amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [12.9 kB]
Get:14 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6-cli amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [1301 kB]
Get:15 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libapache2-mod-php5.6 amd64 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [1254 kB]
Get:16 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php5.6 all 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 [264 kB]
Preconfiguring packages ...
Fetched 7493 kB in 4s (2094 kB/s)
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 223516 files and directories currently installed.)
Preparing to unpack .../00-libaprutil1-dbd-sqlite3_1.6.1-2_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../01-libaprutil1-ldap_1.6.1-2_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.6.1-2) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../02-apache2-bin_2.4.29-1ubuntu4.11_amd64.deb ...
Unpacking apache2-bin (2.4.29-1ubuntu4.11) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../03-apache2-utils_2.4.29-1ubuntu4.11_amd64.deb ...
Unpacking apache2-utils (2.4.29-1ubuntu4.11) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../04-apache2-data_2.4.29-1ubuntu4.11_all.deb ...
Unpacking apache2-data (2.4.29-1ubuntu4.11) ...
Selecting previously unselected package apache2.
Preparing to unpack .../05-apache2_2.4.29-1ubuntu4.11_amd64.deb ...
Unpacking apache2 (2.4.29-1ubuntu4.11) ...
Preparing to unpack .../06-curl_7.58.0-2ubuntu3.8_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.8) over (7.58.0-2ubuntu3.7) ...
Preparing to unpack .../07-libcurl4_7.58.0-2ubuntu3.8_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.8) over (7.58.0-2ubuntu3.7) ...
Selecting previously unselected package php5.6-common.
Preparing to unpack .../08-php5.6-common_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php5.6-common (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php5.6-json.
Preparing to unpack .../09-php5.6-json_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php5.6-json (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php5.6-opcache.
Preparing to unpack .../10-php5.6-opcache_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php5.6-opcache (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php5.6-readline.
Preparing to unpack .../11-php5.6-readline_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php5.6-readline (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php5.6-cli.
Preparing to unpack .../12-php5.6-cli_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php5.6-cli (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package libapache2-mod-php5.6.
Preparing to unpack .../13-libapache2-mod-php5.6_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libapache2-mod-php5.6 (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php5.6.
Preparing to unpack .../14-php5.6_5.6.40-12+ubuntu18.04.1+deb.sury.org+1_all.deb ...
Unpacking php5.6 (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../15-ssl-cert_1.0.39_all.deb ...
Unpacking ssl-cert (1.0.39) ...
Processing triggers for ufw (0.36-0ubuntu0.18.04.1) ...
WARN: uid is 0 but '/' is owned by 501
Processing triggers for ufw (0.36-0ubuntu0.18.04.1) ...
WARN: uid is 0 but '/' is owned by 501
Processing triggers for ureadahead (0.100.0-21) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ...
Setting up apache2-utils (2.4.29-1ubuntu4.11) ...
Setting up php5.6-common (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/5.6/mods-available/calendar.ini with new version

Creating config file /etc/php/5.6/mods-available/ctype.ini with new version

Creating config file /etc/php/5.6/mods-available/exif.ini with new version

Creating config file /etc/php/5.6/mods-available/fileinfo.ini with new version

Creating config file /etc/php/5.6/mods-available/ftp.ini with new version

Creating config file /etc/php/5.6/mods-available/gettext.ini with new version

Creating config file /etc/php/5.6/mods-available/iconv.ini with new version

Creating config file /etc/php/5.6/mods-available/pdo.ini with new version

Creating config file /etc/php/5.6/mods-available/phar.ini with new version

Creating config file /etc/php/5.6/mods-available/posix.ini with new version

Creating config file /etc/php/5.6/mods-available/shmop.ini with new version

Creating config file /etc/php/5.6/mods-available/sockets.ini with new version

Creating config file /etc/php/5.6/mods-available/sysvmsg.ini with new version

Creating config file /etc/php/5.6/mods-available/sysvsem.ini with new version

Creating config file /etc/php/5.6/mods-available/sysvshm.ini with new version

Creating config file /etc/php/5.6/mods-available/tokenizer.ini with new version
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.8) ...
Setting up apache2-data (2.4.29-1ubuntu4.11) ...
Setting up ssl-cert (1.0.39) ...
Setting up php5.6-readline (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/5.6/mods-available/readline.ini with new version
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.25) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libaprutil1-ldap:amd64 (1.6.1-2) ...
Setting up curl (7.58.0-2ubuntu3.8) ...
Setting up php5.6-opcache (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/5.6/mods-available/opcache.ini with new version
Setting up php5.6-json (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/5.6/mods-available/json.ini with new version
Setting up apache2-bin (2.4.29-1ubuntu4.11) ...
Setting up php5.6-cli (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/5.6/cli/php.ini with new version
Setting up libapache2-mod-php5.6 (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Package apache2 is not configured yet. Will defer actions by package libapache2-mod-php5.6.

Creating config file /etc/php/5.6/apache2/php.ini with new version
No module matches 
Setting up apache2 (2.4.29-1ubuntu4.11) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
info: Switch to mpm prefork for package libapache2-mod-php5.6
Module mpm_event disabled.
Enabling module mpm_prefork.
info: Executing deferred 'a2enmod php5.6' for package libapache2-mod-php5.6
Enabling module php5.6.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service โ†’ /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service โ†’ /lib/systemd/system/apache-htcacheclean.service.
Setting up php5.6 (5.6.40-12+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.25) ...
Processing triggers for ufw (0.36-0ubuntu0.18.04.1) ...
WARN: uid is 0 but '/' is owned by 501

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  bc dns-root-data dnsmasq-base ebtables landscape-common liblxc-common
  liblxc1 libuv1 lxcfs lxd lxd-client python3-attr python3-automat
  python3-click python3-colorama python3-constantly python3-hyperlink
  python3-incremental python3-pam python3-pyasn1 python3-pyasn1-modules
  python3-service-identity python3-twisted python3-twisted-bin
  python3-zope.interface uidmap xdelta3
0 upgraded, 0 newly installed, 27 to remove and 383 not upgraded.
After this operation, 51.7 MB disk space will be freed.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 224316 files and directories currently installed.)
Removing landscape-common (18.01-0ubuntu3.3) ...
Removing bc (1.07.1-2) ...
Removing dns-root-data (2018013001) ...
Removing lxd (3.0.3-0ubuntu1~18.04.1) ...
Removing lxd dnsmasq configuration
Removing dnsmasq-base (2.79-1) ...
Removing ebtables (2.0.10.4-3.5ubuntu2.18.04.3) ...
Removing libuv1:amd64 (1.18.0-3) ...
Removing lxcfs (3.0.3-0ubuntu1~18.04.1) ...
Removing lxd-client (3.0.3-0ubuntu1~18.04.1) ...
Removing python3-twisted (17.9.0-2) ...
Removing python3-automat (0.6.0-1) ...
Removing python3-service-identity (16.0.0-2) ...
Removing python3-attr (17.4.0-2) ...
Removing python3-click (6.7-3) ...
Removing python3-colorama (0.3.7-1) ...
Removing python3-constantly (15.1.0-1) ...
Removing python3-hyperlink (17.3.1-2) ...
Removing python3-incremental (16.10.1-3) ...
Removing python3-pam (0.4.2-13.2ubuntu4) ...
Removing python3-pyasn1-modules (0.2.1-0.2) ...
Removing python3-pyasn1 (0.4.2-3) ...
Removing python3-twisted-bin:amd64 (17.9.0-2) ...
Removing python3-zope.interface (4.3.2-1build2) ...
Removing uidmap (1:4.5-1ubuntu2) ...
Removing xdelta3 (3.0.11-dfsg-1ubuntu1) ...
Removing liblxc-common (3.0.3-0ubuntu1~18.04.1) ...
Removing liblxc1 (3.0.3-0ubuntu1~18.04.1) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
update-alternatives: using /usr/bin/php5.6 to provide /usr/bin/php (php) in manual mode
update-alternatives: using /usr/bin/phar5.6 to provide /usr/bin/phar (phar) in manual mode
update-alternatives: using /usr/bin/phar.phar5.6 to provide /usr/bin/phar.phar (phar.phar) in manual mode
Changed current directory to /home/runner/.composer
Using version ^0.3.9 for hirak/prestissimo
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for hirak/prestissimo ^0.3.9 -> satisfiable by hirak/prestissimo[0.3.9].
    - hirak/prestissimo 0.3.9 requires ext-curl * -> the requested PHP extension curl is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/5.6/cli/php.ini
    - /etc/php/5.6/cli/conf.d/10-opcache.ini
    - /etc/php/5.6/cli/conf.d/10-pdo.ini
    - /etc/php/5.6/cli/conf.d/20-amqp.ini
    - /etc/php/5.6/cli/conf.d/20-apcu.ini
    - /etc/php/5.6/cli/conf.d/20-calendar.ini
    - /etc/php/5.6/cli/conf.d/20-ctype.ini
    - /etc/php/5.6/cli/conf.d/20-exif.ini
    - /etc/php/5.6/cli/conf.d/20-fileinfo.ini
    - /etc/php/5.6/cli/conf.d/20-ftp.ini
    - /etc/php/5.6/cli/conf.d/20-gettext.ini
    - /etc/php/5.6/cli/conf.d/20-iconv.ini
    - /etc/php/5.6/cli/conf.d/20-igbinary.ini
    - /etc/php/5.6/cli/conf.d/20-json.ini
    - /etc/php/5.6/cli/conf.d/20-memcache.ini
    - /etc/php/5.6/cli/conf.d/20-mongodb.ini
    - /etc/php/5.6/cli/conf.d/20-msgpack.ini
    - /etc/php/5.6/cli/conf.d/20-phar.ini
    - /etc/php/5.6/cli/conf.d/20-posix.ini
    - /etc/php/5.6/cli/conf.d/20-readline.ini
    - /etc/php/5.6/cli/conf.d/20-redis.ini
    - /etc/php/5.6/cli/conf.d/20-shmop.ini
    - /etc/php/5.6/cli/conf.d/20-sockets.ini
    - /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
    - /etc/php/5.6/cli/conf.d/20-sysvsem.ini
    - /etc/php/5.6/cli/conf.d/20-sysvshm.ini
    - /etc/php/5.6/cli/conf.d/20-tokenizer.ini
    - /etc/php/5.6/cli/conf.d/20-xdebug.ini
    - /etc/php/5.6/cli/conf.d/20-yaml.ini
    - /etc/php/5.6/cli/conf.d/20-zmq.ini
    - /etc/php/5.6/cli/conf.d/25-memcached.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, deleting ./composer.json.
PHP 5.6.40-12+ubuntu18.04.1+deb.sury.org+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
Composer version 1.9.0 2019-08-02 20:55:32
curl enabled
mbstring enabled

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 383 not upgraded.
done

Pecl not recognized as the name of a cmdlet

I'm trying to use Pecl under windows. The same setup works fine under linux MacOS

 install-windows:
    needs: build
    runs-on: ${{ matrix.operating-system }}
    strategy:
      fail-fast: false
      matrix:
        operating-system: [windows-latest]
        php-versions: ['7.2', '7.3', '7.4']
    name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
    steps:
      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: ${{ matrix.php-versions }}
          extensions: mbstring, intl, json, psr
          pecl: true
      - name: Install package
        run: pecl install my-package.tgz

I get the following error:

pecl : The term 'pecl' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\a\_temp\d5e656a9-0ff2-4855-94ac-b48d41494579.ps1:2 char:1
+ pecl install my-package.tgz
+ ~~~~
+ CategoryInfo          : ObjectNotFound: (pecl:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException

some PHP Versions get into endless loops

Describe the bug
PHP is seemingly running into endless loops in certain versions.
Actually, only the Version 5.6 seems to work properly for this case.

To Reproduce
You can find the .yml file inside as part of this PR https://github.com/OpenMage/magento-lts/pull/853/checks?check_run_id=317380325

Expected behavior
To have the php command running through as it does in travis.ci
see https://travis-ci.org/OpenMage/magento-lts/jobs/615974331

Screenshots
screenshot from this job run: https://github.com/OpenMage/magento-lts/runs/302616678
image

Additional context
There may be a chance, that the Issue is with Github Actions in general, and not with the setup-php action, but Iam running out of ideas to validate or detect the actual Issue.

I tried out several combinations to group them in separate jobs in different orders.

PHP NTS support on Windows

Hello,

Are there any plans to provide PHP Non-Thread Safe (NTS) support? Right now we can't create a full featured build matrix due to PHP Thread Safe (TS) limitation.

Thank you

PDO drivers list is empty

Describe the bug

PDO drivers are not properly installed on Windows.

To Reproduce

name: Build and Test

on: [push, pull_request]

jobs:
  build:
    name: PHP ${{ matrix.php-versions }} / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        php-versions: ['7.2', '7.3']
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Setup PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: ${{ matrix.php-versions }}
          extension-csv: mbstring, xml, ctype, iconv, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite3, pgsql, phar, fileinfo, sqlite3
          ini-values-csv: post_max_size=256M, short_open_tag=On #optional
          coverage: xdebug #optional
      - name: Check phpinfo()
        run: php -i
      - name: Check Composer Version
        run: composer -V
      - name: Check PHP Extensions
        run: php -m

Expected behavior
PDO drivers list should not be empty.

Additional context
If you trigger a test build, you'll notice that on the ubuntu nodes it will install everything as expected:

PDO
PDO support => enabled
PDO drivers => dblib, firebird, mysql, odbc, pgsql, sqlite

However, when you go to the windows nodes you'll notice that the PDO drivers list is blank despite the fact there is sqlite3

PDO
PDO support => enabled
PDO drivers => 
....
sqlite3
SQLite3 support => enabled
SQLite3 module version => 7.2.24
SQLite Library => 3.28.0

It looks like this issue might be related to #61

Problem installing mongo extension

Describe the bug
When I want to run composer install using this action, the mongo extension seems missing.

To Reproduce
You can find the execution here:
https://github.com/core23/setup-php-mongo-bug/commit/25a4ba2d3b0f1ad5d027c2ab6700f2590b4fafd4/checks?check_suite_id=380472442

on:
  pull_request:
  push:
    branches:
      - master
    tags:
      - "**"

name: "Continuous Integration"

jobs:
  test-mongo:
    name: "Test Mongo"

    runs-on: ubuntu-latest

    strategy:
      matrix:
        php-version:
          - 7.4

    steps:
      - name: "Checkout"
        uses: actions/checkout@v1

      - name: "Install PHP with extensions"
        uses: shivammathur/setup-php@v1
        with:
          coverage: none
          extensions: "mbstring, json, mongo"
          php-version: ${{ matrix.php-version }}

      - name: "Install locked dependencies with composer"
        run: composer install --no-interaction --no-progress --no-suggest

Expected behavior
When adding the mongo extensions, composer will find it.

Extension mbstring not enabling on php7.4 on windows

A windows-2019 / php 7.4 causes an installtion error when ini-values-csv argument is specified.

To Reproduce

name: CI

on: [push]

jobs:
  run:
    runs-on: windows-2019
  - name: 'Preparation (Windows)'
      uses: shivammathur/setup-php@master
      with:
        php-version: 7.4
        ini-values-csv: 'extension=php_mbstring'

Actual

findstr : FINDSTR: Bad command line
At D:\a\graphql\graphql\7.4win32.ps1:44 char:17
+   if(!(php -m | findstr -i ) -and $exist) {
+                 ~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (FINDSTR: Bad command line:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Could not find extension: 
done

image

https://github.com/railt/graphql/runs/237694686

Expected

Add extension=php_mbstring parameter to end of the php.ini file.

intl Could not install intl on PHP 7.3.12

Describe the bug
sporadically we see issues, that the intl extension could not be installed.
it seems this happens from time to time and is not 100% reproducible.

because of the then missing intl extension the build is not stable and our php static analysis tools run into "normalizer" class not found errors

To Reproduce
Please provide the GitHub Action .yml file:
https://github.com/redaxo/redaxo/blob/master/.github/workflows/push.yml

we see it in e.g. https://github.com/redaxo/redaxo/pull/3090/checks?check_run_id=372438603

Expected behavior
the intl extension should get installed properly

Screenshots
example of a psalm build which errors.

grafik

we can see similar problems on phpstan builds.

Slow execution of tests with coverage set to none

Describe the bug
It seems that the execution of tests is too slow on Github Actions. Local execution takes 50-60 seconds without test coverage. On GitHub actions it takes ~30 minutes. From my local installation I know that this slow execution is caused by XDebug (even if test coverage is disabled), but the Github Actions settings include coverage: none and should also disable XDebug. Do you have any idea what could cause this performance difference?

To Reproduce
GitHub Action .yml file:

name: Laravel CI

on:
  pull_request:
    branches:
      - master

jobs:
  laravel-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Copy ENV Laravel Configuration for CI
      run: php -r "file_exists('.env') || copy('.env.ci', '.env');"
    - name: Setup PHP
      uses: shivammathur/setup-php@master
      with:
        php-version: '7.2'
        coverage: none
    - name: Install Dependencies
      run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
    - name: Generate key
      run: php artisan key:generate
    - name: Create Database
      run: |
        mkdir -p database
        touch database/database.sqlite
        php artisan migrate
    - name: Install Laravel Passport
      run: php artisan passport:install
    - name: Yarn production
      run: |
        yarn install --silent
        yarn run prod
    - name: Execute tests (Unit and Feature tests) via PHPUnit
      env:
        DB_CONNECTION: sqlite
        DB_DATABASE: database/database.sqlite
      run: vendor/bin/phpunit --no-coverage

Expected behavior
I expect the ~300 test cases to finish within 5 minutes. The actual result is a time around 30 minutes (see screenshot below).

Screenshot Capture - 2019-12-19 - 16-03-36

Add Symfony CLI suport

Symfony CLI is a command line tool that makes possible to execute a lot of useful thing with Symfony and PHP development in general.

Among other things, ne is really useful in CI: symfony security:check command.

It checks that the composer.json deps are free of security vulnerabilities.

Originally this command was provided by sensiolabs/security-checker but now it is incorporated into Symfony CLI (https://github.com/sensiolabs/security-checker/issues/132#issuecomment-448673498 and https://github.com/sensiolabs/security-checker/pull/144/files#diff-04c6e90faac2675aa89e2176d2eec7d8R8-R13).

Here the installation info: https://symfony.com/download

Some versions of phpdbg are ignoring the __debugInfo magic method

Describe the bug

For some PHP versions, the phpdbg executable provided by this action is ignoring the __debugInfo magic method.

To Reproduce

I've created a repo to reproduce the issue: ezzatron/setup-php-action-repro

But the gist of it is this PHPUnit test, which passes on equivalent Travis CI builds, (and weirdly, only under PHP 7.3 on GitHub Actions?):

<?php

use PHPUnit\Framework\TestCase;

class ReproTest extends TestCase
{
    public function testDebugMagicMethod()
    {
        ob_start();
        var_dump(new ClassA());

        $this->assertRegExp('/\["a"]=>\s+string\(1\) "b"/', ob_get_clean());
    }
}

class ClassA
{
    public function __debugInfo() {
        return ['a' => 'b'];
    }
}

Expected behavior

The tests should pass, like this Travis build: https://travis-ci.org/ezzatron/setup-php-action-repro/builds/618399139

At the moment, they fail like this GitHub Actions build: https://github.com/ezzatron/setup-php-action-repro/commit/cf465a6517a7fd06811997914fe54807e045e235/checks?check_suite_id=333972681

Screenshots

Screen Shot 2019-11-29 at 9 56 55 am

Screen Shot 2019-11-29 at 9 56 38 am

Additional context

I'm the author of Phony, a PHP mocking library. I use the __debugInfo() magic method so that if a developer uses var_dump() on one of Phony's mocks (or something containing a mock), it doesn't produce thousands of lines of output about internal Phony classes. I discovered this bug because I have a test for this behaviour in Phony's test suite.

Update xdebug version to 2.8.1 or new

Is your feature request related to a problem? Please describe.
Update xdebug version >2.8.0 because tests slow executed. See PR in xdebug

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
I try to install another version of xdebug, but i catch segmentation fault. See step

Additional context
Add any other context or screenshots about the feature request here.

Trash files in working directory after setup

Describe the bug
A clear and concise description of what the bug is.

When launched, my working directory contains changes that are not expected or expected. Some files were not cleaned properly after setup scripts were executed.

To Reproduce
Please provide the GitHub Action .yml file.

name: CI

on:
  schedule:
  - cron: 0 0,8,16 * * 0-5

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Setup PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: '5.6'
      - name: Verify working-dir clean
        run: git status

Expected behavior
A clear and concise description of what you expected to happen.

Working directory have following unstaged files:

  • 5.6linux.sh
  • phalcon.sh

Screenshots
If applicable, add screenshots to help explain your problem.

https://github.com/ad-m/cbosa/commit/e73952c05c361050e7006609b1120b96aa19f5ae/checks?check_suite_id=284329170

Additional context
Add any other context about the problem here.

composer timeouts

Describe the bug
On the following setup:

 Set up job2s
Download action repository 'shivammathur/setup-php@master'
Current runner version: '2.160.2'
Prepare workflow directory
Prepare all required actions
Download action repository 'actions/checkout@v1'
Download action repository 'shivammathur/setup-php@master'

Everything was running as expected.

However on:

Current runner version: '2.163.1'
Prepare workflow directory
Prepare all required actions
Download action repository 'actions/checkout@v1'
Download action repository 'shivammathur/setup-php@master'

phpunit is timing out:

  [Symfony\Component\Process\Exception\ProcessTimedOutException]                                       
  The process "vendor/bin/phpunit -vvv --coverage-html coverage" exceeded the timeout of 300 seconds.  

To Reproduce
The actions file: https://github.com/nWidart/laravel-modules/blob/master/.github/workflows/php.yml

Expected behavior
The tests to pass, without timeouts. Locally they run.

Additional context
A failing build: https://github.com/nWidart/laravel-modules/commit/2e12c6149028b4e6bf4dd185330b129ea7fa6228/checks?check_suite_id=396488927

A successful build: https://github.com/nWidart/laravel-modules/commit/4151f9f42887524783385dce0f5bf8735b6b73a3/checks?check_suite_id=324493157

I'm not sure what could cause this. I've seen I could increase the timeout config but that wouldn't really solve the root cause.

Thank you,

php-config for PHP 7.0/7.1 is wrong

      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.1'

      - name: Debug PHP
        run: |
          php -v
          php-config --extension-dir
          which php
          ls -al $(which php)
          which phpize
          ls -al $(which phpize)
          which php-config
          ls -al $(which php-config)
          ls -al /usr/bin/ | grep "php-config"

Outputs

PHP 7.1.33-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 18 2019 14:53:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.0, Copyright (c) 2002-2019, by Derick Rethans
/usr/lib/php/20190902
/usr/bin/php
lrwxrwxrwx 1 root root 21 Jan  3 00:18 /usr/bin/php -> /etc/alternatives/php
/usr/bin/phpize
lrwxrwxrwx 1 root root 24 Jan  3 00:19 /usr/bin/phpize -> /etc/alternatives/phpize
/usr/bin/php-config
lrwxrwxrwx 1 root root 28 Jan  3 00:19 /usr/bin/php-config -> /etc/alternatives/php-config
 lrwxrwxrwx  1 root   root          28 Jan  3 00:19 php-config -> /etc/alternatives/php-config
-rwxr-xr-x  1 root   root        4238 Dec 18 14:48 php-config7.3
-rwxr-xr-x  1 root   root        4379 Dec 18 14:44 php-config7.4

As you can see it is php-config from PHP 7.4, not PHP 7.1 (because /usr/lib/php/20190902). The same issue with phpize and the same for PHP 7.0.

Add Phive to the available tools

Is your feature request related to a problem? Please describe.
Often it happens that dev tools cause conflicts in the tree of dependencies.

To solve this problem it is possible to download some tools as a PHAR package.

To make easier the use of the PHAR packages, a tool exists: Phive.

Phive is like Composer, but for PHAR packages.

It permits to create a list of packages to download as PHAR and makes their management easier.

You can read more about Phive here: https://phar.io/

Describe the solution you'd like
Make possible to use a configuration like this to make Phive available:

            - name: Setup PHP
              uses: shivammathur/setup-php@v1
              with:
                  php-version: ${{ matrix.php }}
                  coverage: none # disable xdebug, pcov
                  tools: phive
                  extensions: intl

Describe alternatives you've considered

Obviously it is possible to install Phive manually, but having the action do it makes thing a lot easier.

Access denied for user in MySQL with the Laravel preset

I've installed this action on my repository, didn't change a thing and it doesn't work with MySQL. The error I keep getting is

 PDOException: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)

This is the .yml file Iโ€™m using.

name: Testing Laravel with MySQL
on: [push]
jobs:
  laravel:
    name: PHP ${{ matrix.php-versions }}
    runs-on: ubuntu-latest
    env:
      DB_DATABASE: officelife
      DB_USERNAME: root
      DB_PASSWORD: password
      BROADCAST_DRIVER: log
      CACHE_DRIVER: redis
      QUEUE_CONNECTION: redis
      SESSION_DRIVER: redis
    services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: false
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: officelife
        ports:
          - 3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      redis:
        image: redis
        ports:
          - 6379/tcp
        options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
    strategy:
      fail-fast: false
      matrix:
        php-versions: ['7.3', '7.4']
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Setup PHP, with composer and extensions
        uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
        with:
          php-version: ${{ matrix.php-versions }}
          extensions: mbstring, dom, fileinfo, mysql
          coverage: none
      - name: Get composer cache directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
      - name: Cache composer dependencies
        uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          # Use composer.json for key, if composer.lock is not committed.
          # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: ${{ runner.os }}-composer-
      - name: Install Composer dependencies
        run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
      - name: Prepare the application
        run: |
          php -r "file_exists('.env') || copy('.env.example', '.env');"
          php artisan key:generate
      - name: Clear Config
        run: php artisan config:clear
      - name: Run Migration
        run: php artisan migrate -v
        env:
          DB_PORT: ${{ job.services.mysql.ports['3306'] }}
      - name: Test with phpunit
        run: vendor/bin/phpunit --coverage-text
        env:
          DB_PORT: ${{ job.services.mysql.ports['3306'] }}

If you had any clue on how to fix this, let me know ๐Ÿ˜€ Thanks for this great action, btw.

Missed pdo_sqlite and gmp

For the following configuration:

      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.0'
          extensions: pdo_sqlite gmp

I get this:

image

Both extensions are standard. And as you can see Action does not trigger error and does not stop CI.

Unable to load Redis extension with PHP 7.4

Describe the bug
Loading redis extension with PHP 7.4 produce the following error message

PHP Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

To Reproduce

      - name: Install PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: 7.4
          extension-csv: redis

or

      - name: Install PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: 7.4
          extension-csv: redis
          pecl: true

Both will cause the same issue

Expected behavior
Being able to load redis without any problem

Screenshots
Screen Shot 2019-12-02 at 5 24 14 PM

Additional context
Add any other context about the problem here.

Sponsor link not working

Displays the following errormessage:

Some errors were encountered when parsing the FUNDING.yml file:

Some users provided are not enrolled in GitHub Sponsors. Apply to Sponsors.
Learn more about formatting FUNDING.yml.

One of the provided options not working is github, and I bet they are "enrolled in GitHub Sponsors" ;)

Allow version number on tools names

Is your feature request related to a problem? Please describe.
There is no way to change a version of a tool

Describe the solution you'd like
I would like to extend the tools string to allow version on the names

tools: composer:1.9.1

if no version is provided use the default behavior

Describe alternatives you've considered
Manual installing on tools

Additional context
n/a

gd is gd2 on Windows

This is not a big issue, but you might want to standardize this.

To Reproduce

runs-on: windows-latest
steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@master
      with:
          php-version: 7.3
          extension-csv: dom, filter, gd, hash, intl, json, pcre, pdo, zlib
          coverage: none

Log

Run shivammathur/setup-php@master
pwsh C:\hostedtoolcache\windows\win32.ps1 -version 7.3 -dir d:\a\_actions\shivammathur\setup-php\master\lib

==> Setup PhpManager 
โˆš PhpManager Installed 

==> Setup PHP and Composer 
โˆš PHP Switched to PHP7.3 
โˆš Composer Installed 

==> Setup Extensions 
โˆš dom Enabled 
โˆš filter Enabled 
โœ— gd Could not find gd for PHP7.3 on PECL 
โˆš hash Enabled 
โˆš intl Enabled 
โˆš json Enabled 
โˆš pcre Enabled 
โˆš pdo Enabled 
โˆš zlib Enabled 

==> Setup Coverage 
โˆš none Disabled Xdebug and PCOV 

Workaround

This is due to the fact that the .dll file is called php_gd2.dll on Windows, so I tried this:

runs-on: windows-latest
steps:
    - name: Setup PHP
      uses: shivammathur/setup-php@master
      with:
          php-version: 7.3
          extension-csv: dom, filter, gd2, hash, intl, json, pcre, pdo, zlib
          coverage: none

Log

==> Setup Extensions 
โˆš dom Enabled 
โˆš filter Enabled 
โˆš gd2 Enabled 
โœ— gd2 Could not find gd2 for PHP7.3 on PECL 
โˆš hash Enabled 
โˆš intl Enabled 
โˆš json Enabled 
โˆš pcre Enabled 
โˆš pdo Enabled 
โˆš zlib Enabled 

As you see, the gd2 extension has now been enabled, however, the script also tried to download it from PECL. Maybe you can unify this, so the script automatically maps gd to gd2 on Windows?

Examples are misleading - Need update

Hello,

I'm using your Github actions in my repositories.
I followed the examples files to enable the dependencies cache to speed up my builds and it failed.

Let's take this example: https://github.com/shivammathur/setup-php/blob/master/examples/slim-framework.yml

We can see that it's trying to get the hash of the file composer.lock which is only there AFTER doing composer install.

I would update the examples accordingly and add the composer install step before the Cache composer dependencies step. For all the examples.

In case of an already existing composer.lock in the repository, it doesn't change a thing.

XML extension missing for PHP 7.0

Describe the bug
When using ubuntu-18.04 with PHP 7.0 the xml extension doesn't seem to be correctly enabled.

To Reproduce
You can find a broken build here https://github.com/IchHabRecht/my_skeleton/runs/350569574
The associated yml file can be found here https://github.com/IchHabRecht/my_skeleton/blob/e5722119639080b445c8550db8a115922e9b165c/.github/workflows/typo3-mysql.yml

Expected behavior
The composer installation for "๐Ÿƒ tests with TYPO3 "^8.7" and PHP 7.0" should be executed without any error.

Additional context
Switching to ubuntu-16.04 everything runs as expected (https://github.com/IchHabRecht/my_skeleton/runs/350584548).

Add a revolving "v1" tag

It seems common practice to add a revolving v1 tag to GitHub actions, so we can require the current major version instead of @master:

Examples

steps:
    - uses: actions/checkout@v1
    - uses: codecov/codecov-action@v1

GitHub also recommends this in their documentation:

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-actions#versioning-your-action

I am not sure how much sense a revolving tag makes, especially as it implies more work on your end (deleting and re-adding it upon every new release). Still I wanted to bring it up to hear your thoughts on this. ๐Ÿ™ˆ

several extensions enabled by default on php7.2, but non 7.0

Describe the bug
using a action which installs via composer sabre/xml I am gettin an error when using php7.0 because of a missing ext-dom extension but on php 7.2 build it works fine

image

in the php 7.0 build the ext-dom extension needs to be explicitly activated via github-action workflow config, but on php 7.2 it works out of the box.

is this difference intentional?

Setting up the action is slow sometimes

in comparison to all other steps within the github action setup-php is comparatively slow.

not sure there is room for improvement but I thought it might be usefull feedback for you. since github action will get payed on a per minute basis after reaching GA the runtime is an important aspect

image

our push.yml does not contain something fancy, so I guess there is not much I can do from a consumer point of view:

name: PHP Checks

on: [push]

jobs:

  phpstan:
    name: PHPStan
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Setup PHP
      uses: shivammathur/setup-php@master
      with:
        php-version: 7.2
    - run: mkdir -p "$HOME/.phpstan" && composer require --dev phpstan/phpstan-shim --working-dir "$HOME/.phpstan"
    - run: composer install # install the apps dependencies
    - run: $HOME/.phpstan/vendor/bin/phpstan analyse -c app/admin/phpstan.neon.dist
    - run: $HOME/.phpstan/vendor/bin/phpstan analyse -c app/shop/phpstan.neon.dist
    - run: $HOME/.phpstan/vendor/bin/phpstan analyse -c app/portal/phpstan.neon.dist

The win32 script is overly complex

The win32.ps1 file is overly complex, it could be simplified by using commands that come with PhpManager.
For example:

Add-Content C:\tools\php\php.ini "extension=php_openssl.dll`nextension=php_curl.dll"

can be replaced by

Enable-PhpExtension openssl,curl

Furthermore, it doesn't configure the curl/openssl extensions to a valid list of Certification Authorities (so, https requests will fail).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.