From a4c66572ab7d009b024edc907c89cd2f8620291f Mon Sep 17 00:00:00 2001 From: Michael Mainer Date: Fri, 20 Mar 2020 01:14:49 -0700 Subject: [PATCH 1/2] Update Install-PHP.ps1 to include Composer 1. Install Composer from Chocolatey. PHP needs its dependency manager. 2. Enable php_openssl.dll - believe this is necessary in the case someone wants to update Composer. **Reference** https://chocolatey.org/packages/composer https://github.com/actions/virtual-environments/issues/587 https://superuser.com/questions/1010080/the-openssl-extension-is-missing-on-windows-while-installing-composer --- images/win/scripts/Installers/Install-PHP.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-PHP.ps1 b/images/win/scripts/Installers/Install-PHP.ps1 index 02d38931d..72db2ee27 100644 --- a/images/win/scripts/Installers/Install-PHP.ps1 +++ b/images/win/scripts/Installers/Install-PHP.ps1 @@ -10,8 +10,11 @@ Import-Module -Name ImageHelpers $installDir = "c:\tools\php" choco install php -y --force --params "/InstallDir:$installDir" -# update path to extensions and enable curl and mbstring extensions -((Get-Content -path $installDir\php.ini -Raw) -replace ';extension=curl','extension=curl' -replace ';extension=mbstring','extension=mbstring' -replace ';extension_dir = "ext"','extension_dir = "ext"') | Set-Content -Path $installDir\php.ini +# Install latest Composer in chocolatey +choco install composer --ia "/DEV=$installDir /PHP=$installDir" + +# update path to extensions and enable curl and mbstring extensions, and enable php openssl extensions. +((Get-Content -path $installDir\php.ini -Raw) -replace ';extension=curl','extension=curl' -replace ';extension=mbstring','extension=mbstring' -replace ';extension_dir = "ext"','extension_dir = "ext"' -replace 'extension=";php_openssl.dll"','extension_dir = "php_openssl.dll"') | Set-Content -Path $installDir\php.ini # Set the PHPROOT environment variable. setx PHPROOT $installDir /M From 030197e844770f3fe5bc46c0544499f43655f9aa Mon Sep 17 00:00:00 2001 From: Michael Mainer Date: Fri, 20 Mar 2020 01:50:21 -0700 Subject: [PATCH 2/2] Update Validate-PHP.ps1 Add validation for composer install --- .../win/scripts/Installers/Validate-PHP.ps1 | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/images/win/scripts/Installers/Validate-PHP.ps1 b/images/win/scripts/Installers/Validate-PHP.ps1 index a8663617f..f2f26a526 100644 --- a/images/win/scripts/Installers/Validate-PHP.ps1 +++ b/images/win/scripts/Installers/Validate-PHP.ps1 @@ -33,6 +33,32 @@ else exit 1 } +# Verify that composer.exe is on the path +if(Get-Command -Name 'composer') +{ + Write-Host "$(composer --version) is on the path." +} +else +{ + Write-Host "composer is not on the path." + exit 1 +} + +# Get the composer version. +$composerVersion = $(composer --version) + +# Add composer version details in Markdown +$SoftwareName = "Composer" +$Description = @" +#### $composerVersion + +_Environment:_ +* PATH: contains the location of composer.exe version $composerVersion +* PHPROOT: root directory of the Composer $composerVersion installation +"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description + # Get available versions of PHP $phpVersionOnPath = Get-PHPVersion -phpRootPath "C:\tools\php72"