diff --git a/internal/services/php.go b/internal/services/php.go
index 8a4ba54f..4e557749 100644
--- a/internal/services/php.go
+++ b/internal/services/php.go
@@ -253,26 +253,15 @@ func (r *PHPImpl) GetExtensions() ([]internal.PHPExtension, error) {
Description: "Gettext 是一个用于处理多语言的库。",
Installed: false,
},
- /*{
+ {
Name: "igbinary",
Slug: "igbinary",
Description: "Igbinary 是一个用于序列化和反序列化数据的库。",
Installed: false,
},
- {
- Name: "swoole",
- Slug: "swoole",
- Description: "Swoole 是一个用于构建高性能的异步并发服务器的 PHP 扩展。",
- Installed: false,
- },
- {
- Name: "swow",
- Slug: "swow",
- Description: "Swow 是一个用于构建高性能的异步并发服务器的 PHP 扩展。",
- Installed: false,
- },*/
}
+ // ionCube 只支持 PHP 8.3 以下版本
if cast.ToUint(r.version) < 83 {
extensions = append(extensions, internal.PHPExtension{
Name: "ionCube",
@@ -281,6 +270,21 @@ func (r *PHPImpl) GetExtensions() ([]internal.PHPExtension, error) {
Installed: false,
})
}
+ // Swoole 和 Swow 不支持 PHP 8.0 以下版本
+ if cast.ToUint(r.version) >= 80 {
+ extensions = append(extensions, internal.PHPExtension{
+ Name: "Swoole",
+ Slug: "swoole",
+ Description: "Swoole 是一个用于构建高性能的异步并发服务器的 PHP 扩展。",
+ Installed: false,
+ })
+ extensions = append(extensions, internal.PHPExtension{
+ Name: "Swow",
+ Slug: "swow",
+ Description: "Swow 是一个用于构建高性能的异步并发服务器的 PHP 扩展。",
+ Installed: false,
+ })
+ }
raw, err := tools.Exec("/www/server/php/" + r.version + "/bin/php -m")
if err != nil {
diff --git a/scripts/php_extensions/igbinary.sh b/scripts/php_extensions/igbinary.sh
new file mode 100644
index 00000000..549b1a7f
--- /dev/null
+++ b/scripts/php_extensions/igbinary.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
+
+: '
+Copyright (C) 2022 - now HaoZi Technology Co., Ltd.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+'
+
+HR="+----------------------------------------------------"
+
+downloadUrl="https://git.haozi.net/opensource/download/-/raw/main/panel/php_extensions"
+action="$1"
+phpVersion="$2"
+igbinaryVersion="3.2.15"
+
+Install() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=igbinary')
+ if [ "${isInstall}" != "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 已安装 igbinary"
+ exit 1
+ fi
+
+ cd /www/server/php/${phpVersion}/src/ext
+ rm -rf igbinary
+ rm -rf igbinary-${igbinaryVersion}.zip
+ wget -T 60 -t 3 -O igbinary-${igbinaryVersion}.zip ${downloadUrl}/igbinary-${igbinaryVersion}.zip
+ wget -T 20 -t 3 -O igbinary-${igbinaryVersion}.zip.checksum.txt ${downloadUrl}/igbinary-${igbinaryVersion}.zip.checksum.txt
+
+ if ! sha256sum --status -c igbinary-${igbinaryVersion}.zip.checksum.txt; then
+ echo -e $HR
+ echo "错误:PHP-${phpVersion} igbinary 源码 checksum 校验失败,文件可能被篡改或不完整,已终止操作"
+ exit 1
+ fi
+
+ unzip igbinary-${igbinaryVersion}.zip
+ mv igbinary-${igbinaryVersion} igbinary
+ rm -f igbinary-${igbinaryVersion}.zip
+ rm -f igbinary-${igbinaryVersion}.zip.checksum.txt
+ cd igbinary
+ /www/server/php/${phpVersion}/bin/phpize
+ ./configure --with-php-config=/www/server/php/${phpVersion}/bin/php-config
+ make
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} igbinary 编译失败"
+ exit 1
+ fi
+ make install
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} igbinary 安装失败"
+ exit 1
+ fi
+
+ sed -i '/;haozi/a\extension=igbinary' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} igbinary 安装成功"
+}
+
+Uninstall() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=igbinary$')
+ if [ "${isInstall}" == "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 未安装 igbinary"
+ exit 1
+ fi
+
+ sed -i '/extension=igbinary/d' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} igbinary 卸载成功"
+}
+
+if [ "$action" == 'install' ]; then
+ Install
+fi
+if [ "$action" == 'uninstall' ]; then
+ Uninstall
+fi
diff --git a/scripts/php_extensions/swoole.sh b/scripts/php_extensions/swoole.sh
new file mode 100644
index 00000000..8db97805
--- /dev/null
+++ b/scripts/php_extensions/swoole.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
+
+: '
+Copyright (C) 2022 - now HaoZi Technology Co., Ltd.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+'
+
+HR="+----------------------------------------------------"
+
+downloadUrl="https://git.haozi.net/opensource/download/-/raw/main/panel/php_extensions"
+action="$1"
+phpVersion="$2"
+swooleVersion="5.1.2"
+
+Install() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=swoole')
+ if [ "${isInstall}" != "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 已安装 swoole"
+ exit 1
+ fi
+
+ cd /www/server/php/${phpVersion}/src/ext
+ rm -rf swoole
+ rm -rf swoole-src-${swooleVersion}.zip
+ wget -T 60 -t 3 -O swoole-src-${swooleVersion}.zip ${downloadUrl}/swoole-src-${swooleVersion}.zip
+ wget -T 20 -t 3 -O swoole-src-${swooleVersion}.zip.checksum.txt ${downloadUrl}/swoole-src-${swooleVersion}.zip.checksum.txt
+
+ if ! sha256sum --status -c swoole-src-${swooleVersion}.zip.checksum.txt; then
+ echo -e $HR
+ echo "错误:PHP-${phpVersion} swoole 源码 checksum 校验失败,文件可能被篡改或不完整,已终止操作"
+ exit 1
+ fi
+
+ unzip swoole-src-${swooleVersion}.zip
+ mv swoole-src-${swooleVersion} swoole
+ rm -f swoole-src-${swooleVersion}.zip
+ rm -f swoole-src-${swooleVersion}.zip.checksum.txt
+ cd swoole
+ /www/server/php/${phpVersion}/bin/phpize
+ ./configure --with-php-config=/www/server/php/${phpVersion}/bin/php-config
+ make
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} swoole 编译失败"
+ exit 1
+ fi
+ make install
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} swoole 安装失败"
+ exit 1
+ fi
+
+ sed -i '/;haozi/a\extension=swoole' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} swoole 安装成功"
+}
+
+Uninstall() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=swoole$')
+ if [ "${isInstall}" == "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 未安装 swoole"
+ exit 1
+ fi
+
+ sed -i '/extension=swoole/d' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} swoole 卸载成功"
+}
+
+if [ "$action" == 'install' ]; then
+ Install
+fi
+if [ "$action" == 'uninstall' ]; then
+ Uninstall
+fi
diff --git a/scripts/php_extensions/swow.sh b/scripts/php_extensions/swow.sh
new file mode 100644
index 00000000..ee57c5f9
--- /dev/null
+++ b/scripts/php_extensions/swow.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
+
+: '
+Copyright (C) 2022 - now HaoZi Technology Co., Ltd.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+'
+
+HR="+----------------------------------------------------"
+
+downloadUrl="https://git.haozi.net/opensource/download/-/raw/main/panel/php_extensions"
+action="$1"
+phpVersion="$2"
+swowVersion="1.4.1"
+
+Install() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=swow')
+ if [ "${isInstall}" != "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 已安装 swow"
+ exit 1
+ fi
+
+ cd /www/server/php/${phpVersion}/src/ext
+ rm -rf swow
+ rm -rf swow-${swowVersion}.zip
+ wget -T 60 -t 3 -O swow-${swowVersion}.zip ${downloadUrl}/swow-${swowVersion}.zip
+ wget -T 20 -t 3 -O swow-${swowVersion}.zip.checksum.txt ${downloadUrl}/swow-${swowVersion}.zip.checksum.txt
+
+ if ! sha256sum --status -c swow-${swowVersion}.zip.checksum.txt; then
+ echo -e $HR
+ echo "错误:PHP-${phpVersion} swow 源码 checksum 校验失败,文件可能被篡改或不完整,已终止操作"
+ exit 1
+ fi
+
+ unzip swow-${swowVersion}.zip
+ mv swow-${swowVersion} swow
+ rm -f swow-${swowVersion}.zip
+ rm -f swow-${swowVersion}.zip.checksum.txt
+ cd swow/ext
+ /www/server/php/${phpVersion}/bin/phpize
+ ./configure --with-php-config=/www/server/php/${phpVersion}/bin/php-config
+ make
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} swow 编译失败"
+ exit 1
+ fi
+ make install
+ if [ "$?" != "0" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} swow 安装失败"
+ exit 1
+ fi
+
+ sed -i '/;haozi/a\extension=swow' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} swow 安装成功"
+}
+
+Uninstall() {
+ # 检查是否已经安装
+ isInstall=$(cat /www/server/php/${phpVersion}/etc/php.ini | grep '^extension=swow$')
+ if [ "${isInstall}" == "" ]; then
+ echo -e $HR
+ echo "PHP-${phpVersion} 未安装 swow"
+ exit 1
+ fi
+
+ sed -i '/extension=swow/d' /www/server/php/${phpVersion}/etc/php.ini
+
+ # 重载PHP
+ systemctl reload php-fpm-${phpVersion}.service
+ echo -e $HR
+ echo "PHP-${phpVersion} swow 卸载成功"
+}
+
+if [ "$action" == 'install' ]; then
+ Install
+fi
+if [ "$action" == 'uninstall' ]; then
+ Uninstall
+fi