Skip to content

Commit

Permalink
Add extension version and env check method (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed May 21, 2024
1 parent 11076b1 commit 4ba92b0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/SPC/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
use SPC\command\ExtractCommand;
use SPC\command\InstallPkgCommand;
use SPC\command\MicroCombineCommand;
use SPC\command\SwitchPhpVersionCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Command\ListCommand;

/**
* static-php-cli console app entry
Expand All @@ -43,6 +42,7 @@ public function __construct()
new DumpLicenseCommand(),
new ExtractCommand(),
new MicroCombineCommand(),
new SwitchPhpVersionCommand(),

// Dev commands
new AllExtCommand(),
Expand All @@ -51,9 +51,4 @@ public function __construct()
]
);
}

protected function getDefaultCommands(): array
{
return [new HelpCommand(), new ListCommand()];
}
}
2 changes: 1 addition & 1 deletion src/SPC/builder/extension/opcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class opcache extends Extension
*/
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000) {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !');
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/SPC/builder/extension/protobuf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\util\CustomExt;

#[CustomExt('protobuf')]
class protobuf extends Extension
{
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later');
}
}
}
7 changes: 7 additions & 0 deletions src/SPC/builder/extension/swow.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
#[CustomExt('swow')]
class swow extends Extension
{
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later');
}
}

public function getUnixConfigureArg(): string
{
$arg = '--enable-swow';
Expand Down

0 comments on commit 4ba92b0

Please sign in to comment.