Skip to content

Commit 91ee94f

Browse files
committed
Add ext-mongodb
1 parent e523fff commit 91ee94f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

config/pkg/ext/ext-mongodb.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ext-mongodb:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: ghrel
6+
repo: mongodb/mongo-php-driver
7+
match: mongodb.+\.tgz
8+
extract: php-src/ext/mongodb
9+
metadata:
10+
license-files: [LICENSE]
11+
license: PHP-3.01
12+
suggests:
13+
- icu
14+
- openssl
15+
- zstd
16+
- zlib
17+
frameworks:
18+
- CoreFoundation
19+
- Security
20+
php-extension:
21+
arg-type: custom

src/Package/Extension/mongodb.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
8+
use StaticPHP\Attribute\Package\Extension;
9+
use StaticPHP\Package\PackageInstaller;
10+
use StaticPHP\Package\PhpExtensionPackage;
11+
12+
#[Extension('mongodb')]
13+
class mongodb extends PhpExtensionPackage
14+
{
15+
#[CustomPhpConfigureArg('Darwin')]
16+
#[CustomPhpConfigureArg('Linux')]
17+
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
18+
{
19+
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
20+
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
21+
$arg .= ' --with-mongodb-sasl=no ';
22+
if ($installer->getLibraryPackage('openssl')) {
23+
$arg .= '--with-mongodb-ssl=openssl';
24+
}
25+
$arg .= $installer->getLibraryPackage('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no ';
26+
$arg .= $installer->getLibraryPackage('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
27+
// $arg .= $installer->getLibraryPackage('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
28+
$arg .= $installer->getLibraryPackage('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
29+
return clean_spaces($arg);
30+
}
31+
32+
public function getSharedExtensionEnv(): array
33+
{
34+
$parent = parent::getSharedExtensionEnv();
35+
$parent['CFLAGS'] .= ' -std=c17';
36+
return $parent;
37+
}
38+
}

0 commit comments

Comments
 (0)