From 06b9ce1b848873717b1865f3e216bef036f5aa6f Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Thu, 30 Mar 2017 20:00:00 +0200 Subject: [PATCH] Improve PHP configuration persistence by using multiple directories in PHP_INI_SCAN_DIR --- php-nts.json | 13 +++++++++---- php.json | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/php-nts.json b/php-nts.json index c50388996c..296fb373ad 100644 --- a/php-nts.json +++ b/php-nts.json @@ -29,18 +29,23 @@ "php-cgi.exe" ], "persist": [ - "conf", + "cli", [ "php.ini-production", - "conf\\php.ini" + "cli\\php.ini" ] ], "env_set": { - "PHP_INI_SCAN_DIR": "$dir\\conf" + "PHP_INI_SCAN_DIR": "$dir\\cli;$dir\\cli\\conf.d;" }, "post_install": " +# Create directory for custom PHP configuration +if(!(Test-Path \"$dir\\cli\\conf.d\")) { + (New-Item -Type directory \"$dir\\cli\\conf.d\") | Out-Null +} + # Enable extensions to be found in installation-relative folder (the default is to search C:/php) -(gc \"$dir\\conf\\php.ini\") | % { $_ -replace '; extension_dir = \"ext\"', 'extension_dir = \"ext\"' } | sc \"$dir\\conf\\php.ini\" +(gc \"$dir\\cli\\php.ini\") | % { $_ -replace '; extension_dir = \"ext\"', 'extension_dir = \"ext\"' } | sc \"$dir\\cli\\php.ini\" ", "checkver": { "url": "http://windows.php.net/download/", diff --git a/php.json b/php.json index 4cd5984dd9..5f5242078e 100644 --- a/php.json +++ b/php.json @@ -29,24 +29,29 @@ "php-cgi.exe" ], "persist": [ - "conf", + "cli", [ "php.ini-production", - "conf\\php.ini" + "cli\\php.ini" ] ], "env_set": { - "PHP_INI_SCAN_DIR": "$dir\\conf" + "PHP_INI_SCAN_DIR": "$dir\\cli;$dir\\cli\\conf.d;" }, "post_install": " +# Create directory for custom PHP configuration +if(!(Test-Path \"$dir\\cli\\conf.d\")) { + (New-Item -Type directory \"$dir\\cli\\conf.d\") | Out-Null +} + # Copy ini scan dir from old location before persistent update -if ((Test-Path \"$dir\\..\\conf\") -and !(Test-Path \"$dir\\conf\")) { - Write-Host -ForegroundColor Cyan 'We are moving your php configuration to $dir\\conf' - Move-Item \"$dir\\..\\conf\" \"$dir\\conf\" +if ((Test-Path \"$dir\\..\\conf\") -and !(Test-Path \"$dir\\cli\\conf.d\")) { + Write-Host -ForegroundColor Cyan 'We are moving your php configuration to $dir\\cli\\conf.d' + Move-Item \"$dir\\..\\conf\" \"$dir\\cli\\conf.d\" } # Enable extensions to be found in installation-relative folder (the default is to search C:/php) -(gc \"$dir\\conf\\php.ini\") | % { $_ -replace '; extension_dir = \"ext\"', 'extension_dir = \"ext\"' } | sc \"$dir\\conf\\php.ini\" +(gc \"$dir\\cli\\php.ini\") | % { $_ -replace '; extension_dir = \"ext\"', 'extension_dir = \"ext\"' } | sc \"$dir\\cli\\php.ini\" ", "checkver": { "url": "http://windows.php.net/download/",