mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 05:23:03 +07:00
Refactor INI directives to configs
This commit is contained in:
parent
de4fdb85b9
commit
1fd26e45c8
3
src/configs/ini/jit.ini
Normal file
3
src/configs/ini/jit.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
opcache.enable=1
|
||||||
|
opcache.jit_buffer_size=256M
|
||||||
|
opcache.jit=1235
|
2
src/configs/ini/php.ini
Normal file
2
src/configs/ini/php.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
date.timezone=UTC
|
||||||
|
memory_limit=-1
|
1
src/configs/ini/xdebug.ini
Normal file
1
src/configs/ini/xdebug.ini
Normal file
@ -0,0 +1 @@
|
|||||||
|
xdebug.mode=coverage
|
@ -83,11 +83,11 @@ self_hosted_setup() {
|
|||||||
|
|
||||||
# Function to configure PHP
|
# Function to configure PHP
|
||||||
configure_php() {
|
configure_php() {
|
||||||
(
|
ini_config_dir="${dist:?}"/../src/configs/ini
|
||||||
echo -e "date.timezone=UTC\nmemory_limit=-1"
|
ini_files=("$ini_config_dir"/php.ini)
|
||||||
[[ "$version" =~ $jit_versions ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235"
|
[[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
|
||||||
[[ "$version" =~ $xdebug3_versions ]] && echo -e "xdebug.mode=coverage"
|
[[ "$version" =~ $xdebug3_versions ]] && ini_files+=("$ini_config_dir"/xdebug.ini)
|
||||||
) | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
cat "${ini_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get PHP version in semver format.
|
# Function to get PHP version in semver format.
|
||||||
|
@ -129,6 +129,15 @@ Function Add-PhpCAInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set PHP config.
|
||||||
|
Function Add-PhpConfig {
|
||||||
|
$ini_config_dir = "$dist\..\src\configs\ini"
|
||||||
|
$ini_files = @("$ini_config_dir\php.ini")
|
||||||
|
$version -match $jit_versions -and ($ini_files += ("$ini_config_dir\jit.ini")) > $null 2>&1
|
||||||
|
$version -match $xdebug3_versions -and ($ini_files += ("$ini_config_dir\xdebug.ini")) > $null 2>&1
|
||||||
|
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
|
||||||
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
$tick = ([char]8730)
|
$tick = ([char]8730)
|
||||||
$cross = ([char]10007)
|
$cross = ([char]10007)
|
||||||
@ -141,6 +150,7 @@ $current_profile = "$env:TEMP\setup-php.ps1"
|
|||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$jit_versions = '8.[0-9]'
|
$jit_versions = '8.[0-9]'
|
||||||
$nightly_versions = '8.[2-9]'
|
$nightly_versions = '8.[2-9]'
|
||||||
|
$xdebug3_versions = "7.[2-4]|8.[0-9]"
|
||||||
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
||||||
|
|
||||||
$arch = 'x64'
|
$arch = 'x64'
|
||||||
@ -217,9 +227,6 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
|
|||||||
} catch { }
|
} catch { }
|
||||||
} else {
|
} else {
|
||||||
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
||||||
if($version -match $jit_versions) {
|
|
||||||
('opcache.enable=1', 'opcache.jit_buffer_size=256M', 'opcache.jit=1235') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
||||||
}
|
|
||||||
if($env:update -eq 'true') {
|
if($env:update -eq 'true') {
|
||||||
Update-Php $php_dir >$null 2>&1
|
Update-Php $php_dir >$null 2>&1
|
||||||
$status = "Updated to"
|
$status = "Updated to"
|
||||||
@ -233,7 +240,6 @@ if($installed.MajorMinorVersion -ne $version) {
|
|||||||
Add-Log $cross "PHP" "Could not setup PHP $version"
|
Add-Log $cross "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
||||||
if($version -lt "5.5") {
|
if($version -lt "5.5") {
|
||||||
('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri "$php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $php_dir\$_ >$null 2>&1 }
|
('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri "$php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $php_dir\$_ >$null 2>&1 }
|
||||||
} else {
|
} else {
|
||||||
@ -241,6 +247,7 @@ if($version -lt "5.5") {
|
|||||||
}
|
}
|
||||||
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
||||||
Add-PhpCAInfo
|
Add-PhpCAInfo
|
||||||
|
Add-PhpConfig
|
||||||
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||||
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
||||||
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|
||||||
|
Loading…
Reference in New Issue
Block a user