mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support for pecl_http on Windows for PHP 7.1 to 8.0
This commit is contained in:
parent
356e1a5128
commit
57c17e3349
@ -3,7 +3,7 @@ import * as extensions from '../src/extensions';
|
||||
describe('Extension tests', () => {
|
||||
it('checking addExtensionOnWindows', async () => {
|
||||
let win32: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
|
||||
'Xdebug, pcov, sqlite, :intl, phalcon4, pecl_http, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
@ -12,6 +12,7 @@ describe('Extension tests', () => {
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
expect(win32).toContain('Remove-Extension intl');
|
||||
expect(win32).toContain('Add-Phalcon phalcon4');
|
||||
expect(win32).toContain('Add-Http');
|
||||
expect(win32).toContain('Add-Ioncube');
|
||||
expect(win32).toContain('Add-Oci oci8');
|
||||
expect(win32).toContain('Add-Oci pdo_oci');
|
||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1405,7 +1405,7 @@ exports.scriptTool = scriptTool;
|
||||
* @param os_version
|
||||
*/
|
||||
async function customPackage(pkg, type, version, os_version) {
|
||||
const pkg_name = pkg.replace(/\d+|pdo[_-]/, '');
|
||||
const pkg_name = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||
const script_extension = await scriptExtension(os_version);
|
||||
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
||||
const command = await getCommand(os_version, pkg_name);
|
||||
@ -2986,10 +2986,12 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
// match pdo_oci and oci8
|
||||
// match 5.3ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
// match 7.1pecl_http...8.0pecl_http and 7.1http...8.0http
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
case /^(7\.[1-4]|8\.0)(http|pecl_http)$/.test(version_extension):
|
||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
|
@ -136,12 +136,14 @@ export async function addExtensionWindows(
|
||||
// match pdo_oci and oci8
|
||||
// match 5.3ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
// match 7.1pecl_http...8.0pecl_http and 7.1http...8.0http
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
case /^(7\.[1-4]|8\.0)(http|pecl_http)$/.test(version_extension):
|
||||
add_script += await utils.customPackage(
|
||||
ext_name,
|
||||
'ext',
|
||||
|
55
src/scripts/ext/http.ps1
Normal file
55
src/scripts/ext/http.ps1
Normal file
@ -0,0 +1,55 @@
|
||||
Function Get-ICUUrl() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$icu_version,
|
||||
[Parameter(Position = 1, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$arch,
|
||||
[Parameter(Position = 2, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$vs_version
|
||||
)
|
||||
$trunk = "https://windows.php.net"
|
||||
$urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}")
|
||||
foreach ($url in $urls) {
|
||||
$web_content = Invoke-WebRequest -Uri $url
|
||||
foreach ($link in $web_content.Links) {
|
||||
if ($link -match "/.*ICU-${icu_version}.*/") {
|
||||
return $trunk + $link.HREF
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function Repair-ICU() {
|
||||
$icu = deplister $ext_dir\php_http.dll | Select-String "icu[a-z]+(\d+).dll,([A-Z]+)" | Foreach-Object { $_.Matches }
|
||||
if($icu -and $icu.Groups[2].Value -ne 'OK') {
|
||||
$vs = "vs" + $installed.VCVersion
|
||||
if ($installed.VCVersion -lt 16) {
|
||||
$vs = "vc" + $installed.VCVersion
|
||||
}
|
||||
$zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs
|
||||
if ($zip_url -ne '') {
|
||||
New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" | Out-Null
|
||||
Invoke-WebRequest -Uri $zip_url -OutFile "$php_dir\icu\icu.zip"
|
||||
Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force
|
||||
Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function Add-Http() {
|
||||
Add-Extension raphf >$null 2>&1
|
||||
if($version -lt '8.0') {
|
||||
Add-Extension propro >$null 2>&1
|
||||
}
|
||||
Add-Extension pecl_http >$null 2>&1
|
||||
Repair-ICU
|
||||
try {
|
||||
php --ri "http" 2> $null | Out-Null
|
||||
Add-Log $tick "http" "Installed and enabled"
|
||||
} catch {
|
||||
Add-Log $cross "http" "Could not install http on PHP $( $installed.FullVersion )"
|
||||
}
|
||||
}
|
@ -428,7 +428,7 @@ export async function customPackage(
|
||||
version: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
const pkg_name: string = pkg.replace(/\d+|pdo[_-]/, '');
|
||||
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||
const script_extension: string = await scriptExtension(os_version);
|
||||
const script: string = path.join(
|
||||
__dirname,
|
||||
|
Loading…
Reference in New Issue
Block a user