mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 14:55:39 +08:00
Compare commits
25 Commits
2.0-rc9
...
pmmp-exper
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee3be6f374 | ||
|
|
a39cd9a238 | ||
|
|
2d437952f2 | ||
|
|
7e5b0d6f43 | ||
|
|
cf198e0f0a | ||
|
|
248918e458 | ||
|
|
c4cfc01b88 | ||
|
|
339c03adb2 | ||
|
|
48551cc602 | ||
|
|
e0550b4a45 | ||
|
|
93a55e87d5 | ||
|
|
e68f1ce3fe | ||
|
|
3573007485 | ||
|
|
b961c34d9a | ||
|
|
33e1759caa | ||
|
|
fbf5c958d0 | ||
|
|
672a4102cd | ||
|
|
52d61365b7 | ||
|
|
3604ea6d67 | ||
|
|
967292be5c | ||
|
|
4f5335bba4 | ||
|
|
0569c69634 | ||
|
|
1b734073b0 | ||
|
|
47d068e6d3 | ||
|
|
4537bfb247 |
11
README.md
11
README.md
@@ -18,10 +18,9 @@ You can also use the micro binary file to combine php binary and php source code
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
|
||||
|
||||
[]()
|
||||
[]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html))
|
||||
[]()
|
||||
|
||||
## Documentation
|
||||
@@ -36,9 +35,9 @@ If you don't want to compile yourself, you can download example pre-compiled art
|
||||
Below are several precompiled static-php binaries with different extension combinations,
|
||||
which can be downloaded directly according to your needs.
|
||||
|
||||
- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB.
|
||||
- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` combination contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size.
|
||||
- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` combination contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size.
|
||||
- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB.
|
||||
- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size.
|
||||
- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size.
|
||||
|
||||
## Use static-php-cli to build PHP
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
|
||||
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
|
||||
|
||||
# set download dir
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||
|
||||
# use china mirror
|
||||
@@ -46,7 +46,7 @@ done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
||||
;;
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
"calendar": {
|
||||
"type": "builtin"
|
||||
},
|
||||
"crypto": {
|
||||
"type": "external",
|
||||
"arg-type": "with",
|
||||
"source": "ext-crypto",
|
||||
"lib-depends": [
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"ctype": {
|
||||
"type": "builtin"
|
||||
},
|
||||
@@ -122,6 +130,10 @@
|
||||
"libiconv"
|
||||
]
|
||||
},
|
||||
"igbinary": {
|
||||
"type": "external",
|
||||
"source": "igbinary"
|
||||
},
|
||||
"imagick": {
|
||||
"type": "external",
|
||||
"source": "ext-imagick",
|
||||
@@ -164,6 +176,14 @@
|
||||
"openssl"
|
||||
]
|
||||
},
|
||||
"leveldb": {
|
||||
"type": "external",
|
||||
"arg-type": "with-prefix",
|
||||
"source": "pmmp-leveldb",
|
||||
"lib-depends": [
|
||||
"leveldb"
|
||||
]
|
||||
},
|
||||
"mbregex": {
|
||||
"type": "builtin",
|
||||
"arg-type": "custom",
|
||||
@@ -213,6 +233,10 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"morton": {
|
||||
"type": "external",
|
||||
"source": "ext-morton"
|
||||
},
|
||||
"mysqli": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with",
|
||||
@@ -242,6 +266,13 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"password-argon2": {
|
||||
"type": "builtin",
|
||||
"arg-type": "with-prefix",
|
||||
"lib-depends": [
|
||||
"libargon2"
|
||||
]
|
||||
},
|
||||
"pcntl": {
|
||||
"type": "builtin",
|
||||
"unix-only": true
|
||||
@@ -292,6 +323,16 @@
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"pmmp-chunkutils2": {
|
||||
"type": "external",
|
||||
"source": "pmmp-chunkutils2",
|
||||
"arg-type": "custom",
|
||||
"cpp-extension": true
|
||||
},
|
||||
"pmmpthread": {
|
||||
"type": "external",
|
||||
"source": "pmmpthread"
|
||||
},
|
||||
"posix": {
|
||||
"type": "builtin",
|
||||
"unix-only": true
|
||||
|
||||
@@ -163,6 +163,19 @@
|
||||
"libsodium"
|
||||
]
|
||||
},
|
||||
"leveldb": {
|
||||
"source": "leveldb",
|
||||
"static-libs-unix": [
|
||||
"libleveldb.a"
|
||||
],
|
||||
"cpp-library": true
|
||||
},
|
||||
"libargon2": {
|
||||
"source": "libargon2",
|
||||
"static-libs-unix": [
|
||||
"libargon2.a"
|
||||
]
|
||||
},
|
||||
"libavif": {
|
||||
"source": "libavif",
|
||||
"static-libs-unix": [
|
||||
|
||||
@@ -42,6 +42,16 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"ext-crypto": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/crypto",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/bukka/php-crypto.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-event": {
|
||||
"type": "url",
|
||||
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz",
|
||||
@@ -80,6 +90,16 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-morton": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/morton",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/pmmp/ext-morton.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"ext-snappy": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/snappy",
|
||||
@@ -136,6 +156,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"igbinary": {
|
||||
"type": "ghtar",
|
||||
"path": "php-src/ext/igbinary",
|
||||
"repo": "igbinary/igbinary",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"imagemagick": {
|
||||
"type": "ghtar",
|
||||
"repo": "ImageMagick/ImageMagick",
|
||||
@@ -172,6 +201,24 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"leveldb": {
|
||||
"type": "git",
|
||||
"rev": "mojang-compatible",
|
||||
"url": "https://github.com/pmmp/leveldb.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libargon2": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/mpociot/phc-winner-argon2",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libavif": {
|
||||
"type": "ghtar",
|
||||
"repo": "AOMediaCodec/libavif",
|
||||
@@ -376,14 +423,41 @@
|
||||
}
|
||||
},
|
||||
"pkg-config": {
|
||||
"type": "filelist",
|
||||
"url": "https://pkgconfig.freedesktop.org/releases/",
|
||||
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"pmmp-chunkutils2": {
|
||||
"type": "ghtar",
|
||||
"path": "php-src/ext/chunkutils2",
|
||||
"repo": "pmmp/ext-chunkutils2",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"pmmp-leveldb": {
|
||||
"type": "git",
|
||||
"path": "php-src/ext/leveldb",
|
||||
"rev": "pmmp-mojang-compatible",
|
||||
"url": "https://github.com/pmmp/php-leveldb.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"pmmpthread": {
|
||||
"type": "ghtar",
|
||||
"path": "php-src/ext/pmmpthread",
|
||||
"repo": "pmmp/ext-pmmpthread",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"postgresql": {
|
||||
"type": "url",
|
||||
"url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz",
|
||||
|
||||
21
src/SPC/builder/extension/password_argon2.php
Normal file
21
src/SPC/builder/extension/password_argon2.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('password-argon2')]
|
||||
class password_argon2 extends Extension
|
||||
{
|
||||
public function runCliCheck(): void
|
||||
{
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/SPC/builder/extension/pmmp_chunkutils2.php
Normal file
22
src/SPC/builder/extension/pmmp_chunkutils2.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('pmmp-chunkutils2')]
|
||||
class pmmp_chunkutils2 extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'chunkutils2';
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--enable-chunkutils2';
|
||||
}
|
||||
}
|
||||
12
src/SPC/builder/linux/library/leveldb.php
Normal file
12
src/SPC/builder/linux/library/leveldb.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
class leveldb extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\leveldb;
|
||||
|
||||
public const NAME = 'leveldb';
|
||||
}
|
||||
25
src/SPC/builder/linux/library/libargon2.php
Normal file
25
src/SPC/builder/linux/library/libargon2.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libargon2 extends LinuxLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libargon2;
|
||||
|
||||
public const NAME = 'libargon2';
|
||||
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
// detect libsodium (The libargon2 conflicts with the libsodium library.)
|
||||
if ($this->builder->getLib('libsodium') !== null) {
|
||||
throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !');
|
||||
}
|
||||
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
12
src/SPC/builder/macos/library/leveldb.php
Normal file
12
src/SPC/builder/macos/library/leveldb.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class leveldb extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\leveldb;
|
||||
|
||||
public const NAME = 'leveldb';
|
||||
}
|
||||
12
src/SPC/builder/macos/library/libargon2.php
Normal file
12
src/SPC/builder/macos/library/libargon2.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
class libargon2 extends MacOSLibraryBase
|
||||
{
|
||||
use \SPC\builder\unix\library\libargon2;
|
||||
|
||||
public const NAME = 'libargon2';
|
||||
}
|
||||
33
src/SPC/builder/unix/library/leveldb.php
Normal file
33
src/SPC/builder/unix/library/leveldb.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait leveldb
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
// CMake needs a clean build directory
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
// Start build
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
"cmake {$this->builder->makeCmakeArgs()} " .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DLEVELDB_BUILD_TESTS=OFF ' .
|
||||
'-DLEVELDB_BUILD_BENCHMARKS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
}
|
||||
}
|
||||
26
src/SPC/builder/unix/library/libargon2.php
Normal file
26
src/SPC/builder/unix/library/libargon2.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait libargon2
|
||||
{
|
||||
protected function build()
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make PREFIX='' clean")
|
||||
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||
|
||||
$this->patchPkgconfPrefix(['libargon2.pc']);
|
||||
|
||||
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||
if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
# If you want to test new extensions here, just modify it.
|
||||
$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
|
||||
$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
|
||||
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
$extensions .= ',sodium';
|
||||
}
|
||||
|
||||
echo $extensions;
|
||||
|
||||
Reference in New Issue
Block a user