After struggling to get a consistent PHP install experience on AppVeyor via Chocolatey in my last post, I decided to solve the issue through a separate Powershell script. I now have it boiled down to a single script that installs the PHP version I request, including:

  • Arch type: x86, x64
  • Thread-Safe version or not
  • A specific version (ie -Version 7.1.1) or the highest build version (ie. -Highest -Version 7.1)
  • Set the install path
  • Set a list of extensions to enable by default (ie. -Extensions openssl,intl,mbstring)

The script will download the correct version of PHP and install the needed VC redistributable. It only requires two lines in your AppVeyor file. An example of testing against several major versions of PHP:

environment:
  matrix:
    - PHP_VERSION: "5.6"
    - PHP_VERSION: "7.0"
    - PHP_VERSION: "7.1"

install:
  - ps: Invoke-WebRequest "https://raw.githubusercontent.com/ChadSikorra/ps-install-php/master/Install-PHP.ps1" -OutFile "Install-PHP.ps1"
  - ps: .\Install-PHP.ps1 -Version $Env:PHP_VERSION -Highest -Arch x64 -Extensions mbstring,intl,openssl
  - refreshenv
  - cd C:\projects\myproject
  - php -r "readfile('https://getcomposer.org/installer');" | php

The install script itself is hosted here:

https://github.com/ChadSikorra/ps-install-php

Feel free to fork it and make whatever modifications you need.

Next Post Previous Post