mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 16:55:38 +08:00
Add several extensions and libs for windows
exts: bz2, sqlsrv, pdo_sqlsrv, yaml, zip, rar libs: bzip2, libyaml, libzip, xz
This commit is contained in:
36
src/SPC/builder/extension/sqlsrv.php
Normal file
36
src/SPC/builder/extension/sqlsrv.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('sqlsrv')]
|
||||
class sqlsrv extends Extension
|
||||
{
|
||||
private bool $pdo_sqlsrv_patched = false;
|
||||
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Windows' && $this->builder->getExt('pdo_sqlsrv') === null) {
|
||||
// support sqlsrv without pdo_sqlsrv
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', 'PHP_PDO_SQLSRV', '"no"');
|
||||
$this->pdo_sqlsrv_patched = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
if ($this->pdo_sqlsrv_patched) {
|
||||
// revert pdo_sqlsrv patch
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', '"no" == "no"', 'PHP_PDO_SQLSRV == "no"');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user