Add ext-mongodb

This commit is contained in:
crazywhalecc 2026-03-12 14:19:38 +08:00
parent e523fff0ab
commit 91ee94f349
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,21 @@
ext-mongodb:
type: php-extension
artifact:
source:
type: ghrel
repo: mongodb/mongo-php-driver
match: mongodb.+\.tgz
extract: php-src/ext/mongodb
metadata:
license-files: [LICENSE]
license: PHP-3.01
suggests:
- icu
- openssl
- zstd
- zlib
frameworks:
- CoreFoundation
- Security
php-extension:
arg-type: custom

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('mongodb')]
class mongodb extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
{
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
$arg .= ' --with-mongodb-sasl=no ';
if ($installer->getLibraryPackage('openssl')) {
$arg .= '--with-mongodb-ssl=openssl';
}
$arg .= $installer->getLibraryPackage('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no ';
$arg .= $installer->getLibraryPackage('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
// $arg .= $installer->getLibraryPackage('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
$arg .= $installer->getLibraryPackage('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
return clean_spaces($arg);
}
public function getSharedExtensionEnv(): array
{
$parent = parent::getSharedExtensionEnv();
$parent['CFLAGS'] .= ' -std=c17';
return $parent;
}
}