From 201e8c8d98995b8a881324216409f1a4e9928087 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 9 Sep 2019 05:41:17 +0530 Subject: [PATCH] Add support for PHP7.4 --- .github/workflows/workflow.yml | 4 +-- README.md | 4 +++ lib/install.js | 9 +++++++ package-lock.json | 2 +- package.json | 2 +- src/7.4.sh | 48 ++++++++++++++++++++++++++++++++++ src/darwin.sh | 2 -- src/install.ts | 10 +++++++ src/windows.ps1 | 13 ++++++--- 9 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 src/7.4.sh diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 88d6d37f..5c1c77c3 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -8,7 +8,7 @@ jobs: max-parallel: 6 matrix: operating-system: [ubuntu-latest, windows-latest, macOS-latest] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3'] + php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] steps: - name: Checkout uses: actions/checkout@master @@ -27,4 +27,4 @@ jobs: php-version: ${{ matrix.php-versions }} extension-csv: "mbstring, curl, mysqli, json, xml, xdebug, pcov, phpdbg" - name: Testing - run: php -m + run: php -v && composer -V && php -m diff --git a/README.md b/README.md index bc11213f..f29b0119 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ - 7.1 - 7.2 - 7.3 +- 7.4 `7.4.0beta4` on `ubuntu`, and `7.4.0RC1` on `windows` and `macOS` + +**Note:** PHP 7.4 is currently in development, do not use in production. ## OS Support @@ -97,6 +100,7 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) - [Homebrew](https://brew.sh/) - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php) - [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated) +- [phpbrew](https://github.com/phpbrew/phpbrew) ## Further Reading diff --git a/lib/install.js b/lib/install.js index 83e03cbb..654245c8 100644 --- a/lib/install.js +++ b/lib/install.js @@ -104,9 +104,15 @@ function addExtension(extension_csv, version) { }); const response = yield http.get('https://pecl.php.net/package/' + extension); if (response.message.statusCode == 200) { + let extension_version = 'stable'; + if (version == '7.4') { + extension_version = 'alpha'; + } windows += 'try { Install-PhpExtension ' + extension + + ' -MinimumStability ' + + extension_version + ' } catch [Exception] { echo $_; echo "Could not install extension: "' + extension + ' }\n'; @@ -161,6 +167,9 @@ function run() { version = core.getInput('php-version', { required: true }); } console.log('Input: ' + version); + if (version == '7.4') { + darwin = fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8'); + } let extension_csv = process.env['extension-csv']; if (!extension_csv) { extension_csv = core.getInput('extension-csv'); diff --git a/package-lock.json b/package-lock.json index 4408f379..9d5b8202 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.1.2", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0241a849..21f9ba86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.1.2", + "version": "1.2.0", "private": false, "description": "Setup php action", "main": "lib/setup-php.js", diff --git a/src/7.4.sh b/src/7.4.sh new file mode 100644 index 00000000..3ccdda20 --- /dev/null +++ b/src/7.4.sh @@ -0,0 +1,48 @@ +brew fetch autoconf& brew fetch automake& brew fetch pcre& brew fetch libtool& brew fetch libpng& brew fetch webp& brew fetch jpeg& brew fetch freetype& brew fetch libxml2& brew fetch pkg-config& brew fetch krb5& brew fetch icu4c& brew fetch re2c& brew fetch bison& brew fetch libzip& brew fetch mcrypt& brew fetch zlib& brew fetch bzip2& brew fetch enchant +brew install autoconf automake pcre libtool libpng webp jpeg freetype libxml2 pkg-config krb5 icu4c re2c bison libzip mcrypt zlib bzip2 enchant >> /dev/null +brew link --force gettext +brew link --force bison +brew link --force openssl +brew link --force libxml2 +brew link --force bzip2 +echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/krb5/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/krb5/sbin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile +echo 'export PATH="/Users/runner/.phpbrew/php/php-7.4.0RC1/bin:$PATH"' >> ~/.bash_profile +source ~/.bash_profile >> /dev/null +export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib" +export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include" +export ENCHANT_LIBS="-L/usr/local/opt/enchant/lib" +export ENCHANT_CFLAGS="-I/usr/local/opt/enchant/include" +export FFI_LIBS="-L/usr/local/opt/libffi/lib" +export FFI_CFLAGS="-I/usr/local/opt/libffi/include" +export ICU_LIBS="-L/usr/local/opt/icu4c/lib" +export ICU_CFLAGS="-I/usr/local/opt/icu4c/include" +export KERBEROS_LIBS="-L/usr/local/opt/krb5/lib" +export KERBEROS_CFLAGS="-I/usr/local/opt/krb5/include" +export OPENSSL_LIBS="-L/usr/local/opt/openssl/lib" +export OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include" +export READLINE_LIBS="-L/usr/local/opt/readline/lib" +export READLINE_CFLAGS="-I/usr/local/opt/readline/include" +export BZIP2_LIBS="-L/usr/local/opt/bzip2/lib" +export BZIP2_CFLAGS="-I/usr/local/opt/bzip2/include" +export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/obzip2pt/libffi/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig" +cd ~ +curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew +chmod +x ./phpbrew +sudo mv phpbrew /usr/local/bin/phpbrew +sudo mkdir -p /opt/phpbrew +phpbrew init --root=/opt/phpbrew +echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc +source ~/.bashrc +phpbrew install -j 10 7.4.0RC1 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml +phpbrew switch php-7.4.0RC1 >> /dev/null +sudo mkdir -p /usr/local/bin +sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC1/bin/php /usr/local/bin/php +brew install composer \ No newline at end of file diff --git a/src/darwin.sh b/src/darwin.sh index ba26b6f1..98c96369 100644 --- a/src/darwin.sh +++ b/src/darwin.sh @@ -1,8 +1,6 @@ echo $1 -ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew unlink php brew tap exolnet/homebrew-deprecated -brew tap homebrew/homebrew-php brew install php@$1 brew link --force --overwrite php@$1 curl -sS https://getcomposer.org/installer | php diff --git a/src/install.ts b/src/install.ts index f7f4db5d..71aaea19 100644 --- a/src/install.ts +++ b/src/install.ts @@ -90,9 +90,15 @@ async function addExtension(extension_csv: string, version: string) { 'https://pecl.php.net/package/' + extension ); if (response.message.statusCode == 200) { + let extension_version = 'stable'; + if (version == '7.4') { + extension_version = 'alpha'; + } windows += 'try { Install-PhpExtension ' + extension + + ' -MinimumStability ' + + extension_version + ' } catch [Exception] { echo $_; echo "Could not install extension: "' + extension + ' }\n'; @@ -142,6 +148,10 @@ async function run() { } console.log('Input: ' + version); + if (version == '7.4') { + darwin = fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8'); + } + let extension_csv = process.env['extension-csv']; if (!extension_csv) { extension_csv = core.getInput('extension-csv'); diff --git a/src/windows.ps1 b/src/windows.ps1 index a9dfa5bc..b093b70c 100644 --- a/src/windows.ps1 +++ b/src/windows.ps1 @@ -2,6 +2,10 @@ param ( [Parameter(Mandatory=$true)][string]$version = "7.3" ) +if($version -eq '7.4') { + $version = '7.4RC1' +} + echo "Installing NuGet" Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force if($version -lt '7.0') { @@ -16,17 +20,20 @@ echo "Installing PhpManager" Install-Module -Name PhpManager -Force -Scope CurrentUser echo "Installing PHP" Uninstall-Php C:\tools\php -Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC +Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production echo "Switch PHP" (Get-PhpSwitcher).targets Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force Switch-Php $version -Force echo "Housekeeping in PHP.ini, enabling openssl" -Move-item -Path C:\tools\php$version\php.ini-production -Destination C:\tools\php$version\php.ini -Force Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'" Set-PhpIniKey extension_dir C:\tools\php$version\ext -Enable-PhpExtension openssl +if($version -lt '7.4') { + Enable-PhpExtension openssl +} else { + Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll" +} echo "Installing Composer" Install-Composer -Scope System -Path C:\tools\php php -v