mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-11-01 15:55:36 +07:00
Add ini_file input to set base php.ini
This commit is contained in:
@ -195,6 +195,18 @@ php_extra_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to set php.ini
|
||||
add_php_config() {
|
||||
if ! [ -e "$ini_dir"/php.ini-development ]; then
|
||||
sudo cp "$ini_dir"/php.ini "$ini_dir"/php.ini-development
|
||||
fi
|
||||
if [[ "$ini" = "production" || "$ini" = "development" ]]; then
|
||||
sudo cp "$ini_dir"/php.ini-"$ini" "$ini_dir"/php.ini
|
||||
elif [ "$ini" = "none" ]; then
|
||||
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to Setup PHP.
|
||||
setup_php() {
|
||||
step_log "Setup PHP"
|
||||
@ -234,8 +246,9 @@ setup_php() {
|
||||
}
|
||||
|
||||
# Variables
|
||||
version=$1
|
||||
dist=$2
|
||||
version=${1:-'8.1'}
|
||||
ini=${2:-'production'}
|
||||
dist=$3
|
||||
php_formula=shivammathur/php/php@"$version"
|
||||
brew_path="$(command -v brew)"
|
||||
brew_path_dir="$(dirname "$brew_path")"
|
||||
|
||||
@ -178,6 +178,27 @@ php_extra_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to set php.ini
|
||||
add_php_config() {
|
||||
php_lib_dir=/usr/lib/php/"$version"
|
||||
current_ini="$php_lib_dir"/php.ini-current
|
||||
current=$(cat "$current_ini" 2>/dev/null)
|
||||
if [ "$current" = "$ini" ]; then
|
||||
return;
|
||||
fi
|
||||
if [[ "$ini" = "production" && "x$current" != "xproduction" ]]; then
|
||||
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-production
|
||||
if [ -e "$php_lib_dir"/php.ini-production.cli ]; then
|
||||
sudo cp "$php_lib_dir"/php.ini-production.cli "$ini_dir"/php.ini
|
||||
fi
|
||||
elif [ "$ini" = "development" ]; then
|
||||
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
|
||||
elif [ "$ini" = "none" ]; then
|
||||
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
||||
fi
|
||||
echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to Setup PHP
|
||||
setup_php() {
|
||||
step_log "Setup PHP"
|
||||
@ -226,8 +247,9 @@ setup_php() {
|
||||
}
|
||||
|
||||
# Variables
|
||||
version=$1
|
||||
dist=$2
|
||||
version=${1:-'8.1'}
|
||||
ini=${2:-'production'}
|
||||
dist=$3
|
||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
||||
scripts="${dist}"/../src/scripts
|
||||
|
||||
@ -135,6 +135,7 @@ self_hosted_setup() {
|
||||
|
||||
# Function to configure PHP
|
||||
configure_php() {
|
||||
add_php_config
|
||||
ini_config_dir="${dist:?}"/../src/configs/ini
|
||||
ini_files=("$ini_config_dir"/php.ini)
|
||||
[[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
|
||||
|
||||
@ -8,6 +8,11 @@ param (
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$ini = 'production',
|
||||
[Parameter(Position = 2, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$dist
|
||||
)
|
||||
|
||||
@ -166,10 +171,18 @@ Function Add-PhpCAInfo {
|
||||
|
||||
# Function to set PHP config.
|
||||
Function Add-PhpConfig {
|
||||
$current = Get-Content -Path $php_dir\php.ini-current -ErrorAction SilentlyContinue
|
||||
if($ini -eq 'development' -or ($ini -eq 'production' -and $current -and $current -ne 'production')) {
|
||||
Copy-Item -Path $php_dir\php.ini-$ini -Destination $php_dir\php.ini -Force
|
||||
} elseif ($ini -eq 'none') {
|
||||
Set-Content -Path $php_dir\php.ini -Value ''
|
||||
}
|
||||
Set-Content -Path $php_dir\php.ini-current -Value $ini
|
||||
$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
|
||||
Add-Content -Path $ini_config_dir\php.ini -Value extension_dir=$ext_dir
|
||||
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
|
||||
}
|
||||
|
||||
@ -257,17 +270,18 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
|
||||
$extra_version = " ($( Get-Content $php_dir\COMMIT ))"
|
||||
}
|
||||
} else {
|
||||
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
||||
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
|
||||
}
|
||||
Add-PhpConfig
|
||||
} catch { }
|
||||
} else {
|
||||
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
||||
if($env:update -eq 'true') {
|
||||
Update-Php $php_dir >$null 2>&1
|
||||
$status = "Updated to"
|
||||
} else {
|
||||
$status = "Found"
|
||||
}
|
||||
Add-PhpConfig
|
||||
}
|
||||
|
||||
$installed = Get-Php -Path $php_dir
|
||||
@ -282,7 +296,6 @@ if($version -lt "5.5") {
|
||||
}
|
||||
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
||||
Add-PhpCAInfo
|
||||
Add-PhpConfig
|
||||
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
||||
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|
||||
|
||||
Reference in New Issue
Block a user