Add ext-protobuf

This commit is contained in:
crazywhalecc 2026-03-12 22:44:57 +08:00
parent 63d28bdc01
commit 067749ab1b
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,9 @@
ext-protobuf:
type: php-extension
artifact:
source:
type: pecl
name: protobuf
metadata:
license-files: [LICENSE]
license: BSD-3-Clause

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\Exception\ValidationException;
use StaticPHP\Package\PackageInstaller;
#[Extension('protobuf')]
class protobuf
{
#[Validate]
public function validate(PackageInstaller $installer): void
{
if (php::getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
}
$grpc = $installer->getPhpExtensionPackage('ext-grpc');
// protobuf conflicts with grpc
if ($grpc?->isBuildStatic()) {
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
}
}
}