crazywhalecc 1 год назад
Родитель
Сommit
f0319de93e
2 измененных файлов с 16 добавлено и 1 удалено
  1. 2 1
      config/ext.json
  2. 14 0
      src/SPC/builder/extension/opcache.php

+ 2 - 1
config/ext.json

@@ -228,7 +228,8 @@
         ]
     },
     "opcache": {
-        "type": "builtin"
+        "type": "builtin",
+        "arg-type": "custom"
     },
     "openssl": {
         "type": "builtin",

+ 14 - 0
src/SPC/builder/extension/opcache.php

@@ -5,11 +5,25 @@ declare(strict_types=1);
 namespace SPC\builder\extension;
 
 use SPC\builder\Extension;
+use SPC\exception\RuntimeException;
+use SPC\exception\WrongUsageException;
 use SPC\util\CustomExt;
 
 #[CustomExt('opcache')]
 class opcache extends Extension
 {
+    /**
+     * @throws WrongUsageException
+     * @throws RuntimeException
+     */
+    public function getUnixConfigureArg(): string
+    {
+        if ($this->builder->getPHPVersionID() < 80000) {
+            throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !');
+        }
+        return '--enable-opcache';
+    }
+
     public function getDistName(): string
     {
         return 'Zend Opcache';