Skip to content

Commit 067749a

Browse files
committed
Add ext-protobuf
1 parent 63d28bd commit 067749a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

config/pkg/ext/ext-protobuf.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ext-protobuf:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: pecl
6+
name: protobuf
7+
metadata:
8+
license-files: [LICENSE]
9+
license: BSD-3-Clause

src/Package/Extension/protobuf.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use Package\Target\php;
8+
use StaticPHP\Attribute\Package\Extension;
9+
use StaticPHP\Attribute\Package\Validate;
10+
use StaticPHP\Exception\ValidationException;
11+
use StaticPHP\Package\PackageInstaller;
12+
13+
#[Extension('protobuf')]
14+
class protobuf
15+
{
16+
#[Validate]
17+
public function validate(PackageInstaller $installer): void
18+
{
19+
if (php::getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
20+
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
21+
}
22+
$grpc = $installer->getPhpExtensionPackage('ext-grpc');
23+
// protobuf conflicts with grpc
24+
if ($grpc?->isBuildStatic()) {
25+
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)