From 9366cbacd93456b4b19a91afd9f6a4da3f679f25 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:06:30 +0800 Subject: [PATCH 1/7] Update discord invite link --- README-zh.md | 2 +- README.md | 2 +- docs/en/guide/index.md | 2 +- docs/zh/guide/index.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README-zh.md b/README-zh.md index e12149b4..3abe0a69 100755 --- a/README-zh.md +++ b/README-zh.md @@ -5,7 +5,7 @@ [![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) [![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) -[![Discord](https://img.shields.io/discord/nrSRbpMJ?label=Discord&logo=discord&style=flat-square)](https://discord.gg/nrSRbpMJ) +[![Discord](https://img.shields.io/discord/nrSRbpMJ?label=Discord&logo=discord&style=flat-square)](https://discord.gg/xf6Rd4pEAk) **StaticPHP** 是一个强大的工具,用于构建可移植的可执行文件,包括 PHP、扩展等。 diff --git a/README.md b/README.md index 85e033f3..e0df9998 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) [![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) -[![Discord](https://img.shields.io/discord/nrSRbpMJ?label=Discord&logo=discord&style=flat-square)](https://discord.gg/nrSRbpMJ) +[![Discord](https://img.shields.io/discord/nrSRbpMJ?label=Discord&logo=discord&style=flat-square)](https://discord.gg/xf6Rd4pEAk) **StaticPHP** is a powerful tool designed for building portable executables including PHP, extensions, and more. diff --git a/docs/en/guide/index.md b/docs/en/guide/index.md index 25be9fc7..30af5667 100644 --- a/docs/en/guide/index.md +++ b/docs/en/guide/index.md @@ -47,7 +47,7 @@ Build your CLI with [symfony/console](https://symfony.com/doc/current/components ## Community -Join our [Discord server](https://discord.gg/nrSRbpMJ) to ask questions, share your builds, and connect with other StaticPHP users. +Join our [Discord server](https://discord.gg/xf6Rd4pEAk) to ask questions, share your builds, and connect with other StaticPHP users. ## Next steps diff --git a/docs/zh/guide/index.md b/docs/zh/guide/index.md index b6a25faa..364e130e 100644 --- a/docs/zh/guide/index.md +++ b/docs/zh/guide/index.md @@ -55,7 +55,7 @@ StaticPHP 支持将 FrankenPHP 连同所需扩展一起静态编译, ## 社区 -加入我们的 [Discord 服务器](https://discord.gg/nrSRbpMJ),提问、分享构建成果,与其他 StaticPHP 用户交流。 +加入我们的 [Discord 服务器](https://discord.gg/xf6Rd4pEAk),提问、分享构建成果,与其他 StaticPHP 用户交流。 ## 接下来 From 5053620b6198e04a071ce4dd899a8f9e6e1f5591 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:07:06 +0800 Subject: [PATCH 2/7] feat: auto-load local working directory registry in vendor mode --- src/bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootstrap.php b/src/bootstrap.php index c300e1f6..f7875e0c 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -77,5 +77,9 @@ if (filter_var(getenv('SPC_ENABLE_LOG_FILE'), FILTER_VALIDATE_BOOLEAN)) { // load core registry Registry::loadRegistry(ROOT_DIR . '/spc.registry.yml'); +// in vendor mode, auto-load the local working directory registry if it exists +if (spc_mode(SPC_MODE_VENDOR) && file_exists(WORKING_DIR . '/spc.registry.yml')) { + Registry::loadRegistry(WORKING_DIR . '/spc.registry.yml'); +} // load registries from environment variable SPC_REGISTRIES Registry::loadFromEnvOrOption(); From e1658bc0e6756840c8ccba29f08d8e9d3df4cdbe Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:09:51 +0800 Subject: [PATCH 3/7] Chore: gettext-win version, password-argon2 deps --- config/pkg/ext/builtin-extensions.yml | 1 + config/pkg/lib/gettext-win.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/pkg/ext/builtin-extensions.yml b/config/pkg/ext/builtin-extensions.yml index 750745cb..c97b32dd 100644 --- a/config/pkg/ext/builtin-extensions.yml +++ b/config/pkg/ext/builtin-extensions.yml @@ -186,6 +186,7 @@ ext-password-argon2: type: php-extension depends: - libargon2 + suggests: - ext-openssl php-extension: os: diff --git a/config/pkg/lib/gettext-win.yml b/config/pkg/lib/gettext-win.yml index 14238307..286f5218 100644 --- a/config/pkg/lib/gettext-win.yml +++ b/config/pkg/lib/gettext-win.yml @@ -4,6 +4,6 @@ gettext-win: source: type: git url: 'https://github.com/winlibs/gettext.git' - rev: master + rev: '0.18' static-libs@windows: - libintl_a.lib From d1b4c0538193ea06387afd093688e91e90d391d2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:11:41 +0800 Subject: [PATCH 4/7] Fix curl exe build on windows --- src/Package/Target/curl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Package/Target/curl.php b/src/Package/Target/curl.php index 43a2904b..3117a8cd 100644 --- a/src/Package/Target/curl.php +++ b/src/Package/Target/curl.php @@ -39,7 +39,7 @@ class curl ->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD')) ->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI')) ->addConfigureArgs( - '-DBUILD_CURL_EXE=OFF', + '-DBUILD_CURL_EXE=ON', '-DZSTD_LIBRARY=zstd_static.lib', '-DBUILD_TESTING=OFF', '-DBUILD_EXAMPLES=OFF', @@ -81,6 +81,7 @@ class curl ->addConfigureArgs( '-DBUILD_CURL_EXE=ON', '-DBUILD_LIBCURL_DOCS=OFF', + '-DOPENSSL_ROOT_DIR=' . BUILD_ROOT_PATH, ) ->build(); @@ -92,6 +93,9 @@ class curl if (str_contains(FileSystem::readFile($pc_path), '-lgssapi_krb5')) { FileSystem::replaceFileRegex($pc_path, '/-lcom_err$/m', '-lcom_err -lkrb5support'); } + // FindThreads can put '-lpthread' into INTERFACE_LINK_LIBRARIES; curl's pc generator + // prepends '-l' to each entry, producing '-l-lpthread'. Strip the extra '-l'. + FileSystem::replaceFileRegex($pc_path, '/-l(-l\S+)/', '$1'); shell()->cd("{$lib->getLibDir()}/cmake/CURL/") ->exec("sed -ie 's|\"/lib/libcurl.a\"|\"{$lib->getLibDir()}/libcurl.a\"|g' CURLTargets-release.cmake"); From df26b93e58b3c08721500c84e67a5e312f180fa9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:12:04 +0800 Subject: [PATCH 5/7] Remove redundant suffix for getClassesPsr4 function --- src/StaticPHP/Util/FileSystem.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StaticPHP/Util/FileSystem.php b/src/StaticPHP/Util/FileSystem.php index 0869bae2..28a4facd 100644 --- a/src/StaticPHP/Util/FileSystem.php +++ b/src/StaticPHP/Util/FileSystem.php @@ -244,6 +244,7 @@ class FileSystem */ public static function getClassesPsr4(string $dir, string $base_namespace, mixed $rule = null, bool|string $return_path_value = false, bool $auto_require = false): array { + $base_namespace = rtrim($base_namespace, '\\'); $classes = []; $files = FileSystem::scanDirFiles($dir, true, true); if ($files === false) { From 82b77af317e4a79266242536f449495fa86e6c5f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 May 2026 18:16:47 +0800 Subject: [PATCH 6/7] Chore: extension fixes clickhouse, mongodb, opcache, password-argon2, pgsql, spx --- src/Package/Extension/clickhouse.php | 15 --------------- src/Package/Extension/mongodb.php | 8 ++++++++ src/Package/Extension/opcache.php | 6 +++++- src/Package/Extension/password_argon2.php | 2 +- src/Package/Extension/pgsql.php | 2 +- src/Package/Extension/spx.php | 13 +++++++++++++ 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Package/Extension/clickhouse.php b/src/Package/Extension/clickhouse.php index 3e11975f..f4e6978d 100644 --- a/src/Package/Extension/clickhouse.php +++ b/src/Package/Extension/clickhouse.php @@ -4,29 +4,14 @@ declare(strict_types=1); namespace Package\Extension; -use Package\Target\php; -use StaticPHP\Attribute\Package\BeforeStage; use StaticPHP\Attribute\Package\CustomPhpConfigureArg; use StaticPHP\Attribute\Package\Extension; -use StaticPHP\Attribute\PatchDescription; use StaticPHP\Package\PackageInstaller; use StaticPHP\Package\PhpExtensionPackage; -use StaticPHP\Util\FileSystem; #[Extension('clickhouse')] class clickhouse extends PhpExtensionPackage { - #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-clickhouse')] - #[PatchDescription('Replace THIS_DIR=`dirname $0` with PHP_EXT_SRCDIR() in config.m4 so include paths resolve to the ext source dir during PHP main configure (dirname $0 returns "." when run from php-src root).')] - public function patchBeforeBuildconfUnix(): void - { - FileSystem::replaceFileRegex( - "{$this->getSourceDir()}/config.m4", - '/^(\s*)THIS_DIR=.*/m', - '$1THIS_DIR=PHP_EXT_SRCDIR()', - ); - } - #[CustomPhpConfigureArg('Darwin')] #[CustomPhpConfigureArg('Linux')] public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string diff --git a/src/Package/Extension/mongodb.php b/src/Package/Extension/mongodb.php index 1b417092..6bf72399 100644 --- a/src/Package/Extension/mongodb.php +++ b/src/Package/Extension/mongodb.php @@ -16,6 +16,14 @@ use StaticPHP\Util\FileSystem; #[Extension('mongodb')] class mongodb extends PhpExtensionPackage { + #[BeforeStage('php', [php::class, 'configureForUnix'], 'ext-mongodb')] + #[PatchDescription('Export PHP_VERSION_ID so mongo-php-driver >= 2.3.3 skips its php-config lookup (in-tree builds have no php-config).')] + public function exportPhpVersionIdForUnix(): void + { + $id = php::getPHPVersionID(); + f_putenv("PHP_VERSION_ID={$id}"); + } + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-mongodb')] #[PatchDescription('Add /utf-8 flag to CFLAGS_MONGODB for Windows build to fix compilation error on non-English Windows.')] public function patchBeforeBuild(): void diff --git a/src/Package/Extension/opcache.php b/src/Package/Extension/opcache.php index 07758de2..699e124d 100644 --- a/src/Package/Extension/opcache.php +++ b/src/Package/Extension/opcache.php @@ -72,6 +72,10 @@ class opcache extends PhpExtensionPackage ) { $opcache_jit = ' --disable-opcache-jit'; } - return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit; + // PHP 8.5+ has opcache built-in + if ($phpVersionID < 80500) { + return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit; + } + return trim($opcache_jit); } } diff --git a/src/Package/Extension/password_argon2.php b/src/Package/Extension/password_argon2.php index 77122405..efef3d05 100644 --- a/src/Package/Extension/password_argon2.php +++ b/src/Package/Extension/password_argon2.php @@ -27,7 +27,7 @@ class password_argon2 extends PhpExtensionPackage #[CustomPhpConfigureArg('Darwin')] public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string { - if ($installer->getLibraryPackage('openssl') !== null) { + if ($installer->getPhpExtensionPackage('openssl')?->isBuildStatic() || $this->isBuildShared()) { if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) { return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead } diff --git a/src/Package/Extension/pgsql.php b/src/Package/Extension/pgsql.php index 6e2b8f0b..b5b22a00 100644 --- a/src/Package/Extension/pgsql.php +++ b/src/Package/Extension/pgsql.php @@ -20,7 +20,7 @@ class pgsql extends PhpExtensionPackage public function getUnixConfigureArg(bool $shared, PackageBuilder $builder, PackageInstaller $installer): string { if (php::getPHPVersionID() >= 80400) { - $libfiles = new SPCConfigUtil(['libs_only_deps' => true, 'absolute_libs' => true])->getPackageDepsConfig('postgresql', array_keys($installer->getResolvedPackages()), $builder->getOption('with-suggests'))['libs']; + $libfiles = new SPCConfigUtil(['libs_only_deps' => true, 'absolute_libs' => true])->getPackageDepsConfig('postgresql', array_keys($installer->getResolvedPackages()))['libs']; $libfiles = str_replace("{$builder->getLibDir()}/lib", '-l', $libfiles); $libfiles = str_replace('.a', '', $libfiles); return '--with-pgsql' . ($shared ? '=shared' : '') . diff --git a/src/Package/Extension/spx.php b/src/Package/Extension/spx.php index bb230ec9..96a8c75d 100644 --- a/src/Package/Extension/spx.php +++ b/src/Package/Extension/spx.php @@ -6,14 +6,27 @@ namespace Package\Extension; use Package\Target\php; use StaticPHP\Attribute\Package\BeforeStage; +use StaticPHP\Attribute\Package\CustomPhpConfigureArg; use StaticPHP\Attribute\Package\Extension; use StaticPHP\Attribute\PatchDescription; +use StaticPHP\Package\PackageInstaller; use StaticPHP\Package\PhpExtensionPackage; use StaticPHP\Util\FileSystem; #[Extension('spx')] class spx extends PhpExtensionPackage { + #[CustomPhpConfigureArg('Linux')] + #[CustomPhpConfigureArg('Darwin')] + public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string + { + $arg = '--enable-SPX' . ($shared ? '=shared' : ''); + if ($installer->getLibraryPackage('zlib') !== null) { + $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; + } + return $arg; + } + #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-spx')] #[PatchDescription('Fix spx extension compile error when building as static')] public function patchBeforeBuildconf(): bool From 3f3edd62a141c22e91a1a748dfdb06b94ea00872 Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 24 May 2026 17:57:02 +0700 Subject: [PATCH 7/7] Update src/Package/Extension/password_argon2.php --- src/Package/Extension/password_argon2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Package/Extension/password_argon2.php b/src/Package/Extension/password_argon2.php index efef3d05..ea8057cc 100644 --- a/src/Package/Extension/password_argon2.php +++ b/src/Package/Extension/password_argon2.php @@ -27,7 +27,7 @@ class password_argon2 extends PhpExtensionPackage #[CustomPhpConfigureArg('Darwin')] public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string { - if ($installer->getPhpExtensionPackage('openssl')?->isBuildStatic() || $this->isBuildShared()) { + if ($installer->getPhpExtensionPackage('openssl')?->isBuildStatic()) { if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) { return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead }