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
This commit is contained in:
Michael Mainer
2020-03-20 01:14:49 -07:00
committed by GitHub
parent 8d7e0391b7
commit a4c66572ab

View File

@@ -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