setup-php/src/windows.ps1

40 lines
1.3 KiB
PowerShell
Raw Normal View History

2019-09-06 06:47:43 +07:00
param (
[Parameter(Mandatory=$true)][string]$version = "7.3"
)
2019-09-09 07:11:17 +07:00
if($version -eq '7.4') {
$version = '7.4RC1'
}
2019-09-06 06:47:43 +07:00
echo "Installing NuGet"
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
if($version -lt '7.0') {
2019-09-07 19:31:50 +07:00
echo "Installing Visual C++"
Install-Module -Name VcRedist -Force
New-Item -Path C:\Temp\VcRedist -ItemType Directory
Get-VcList | Save-VcRedist -Path C:\Temp\VcRedist
$VcList = Get-VcList
Install-VcRedist -Path C:\Temp\VcRedist -VcList $VcList -Silent
2019-09-06 06:47:43 +07:00
}
echo "Installing PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
echo "Installing PHP"
Uninstall-Php C:\tools\php
2019-09-09 07:11:17 +07:00
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production
2019-09-06 06:47:43 +07:00
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"
Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'"
2019-09-07 19:31:50 +07:00
Set-PhpIniKey extension_dir C:\tools\php$version\ext
2019-09-09 07:11:17 +07:00
if($version -lt '7.4') {
Enable-PhpExtension openssl
} else {
Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll"
}
2019-09-06 06:47:43 +07:00
echo "Installing Composer"
2019-09-07 19:31:50 +07:00
Install-Composer -Scope System -Path C:\tools\php
2019-09-06 06:47:43 +07:00
php -v
composer -V