mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 03:15:35 +08:00
Compare commits
18 Commits
2.0-rc1
...
37556c9e02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37556c9e02 | ||
|
|
34cd9d7cc1 | ||
|
|
030ac531a6 | ||
|
|
e19bd39fea | ||
|
|
0fe432dd8e | ||
|
|
c5b24ab136 | ||
|
|
fb06cc1e1a | ||
|
|
71e4ea166c | ||
|
|
fdf8834163 | ||
|
|
1fd70c9a99 | ||
|
|
7c3826f4a4 | ||
|
|
7fb3d05b2c | ||
|
|
f831b4d61d | ||
|
|
56b5c1b138 | ||
|
|
1cca826e8a | ||
|
|
41aa129b97 | ||
|
|
09ba11affb | ||
|
|
2767ac524f |
13
.github/FUNDING.yml
vendored
Normal file
13
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
14
README-en.md
14
README-en.md
@@ -11,8 +11,6 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro
|
|||||||
|
|
||||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||||
|
|
||||||
> This branch is new version, if you are looking for old bash version of static-php-cli, see [bash-version](https://github.com/crazywhalecc/static-php-cli/tree/bash-version).
|
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||||
@@ -129,6 +127,14 @@ If anything goes wrong, use `--debug` option to display full terminal output:
|
|||||||
./bin/spc fetch --all --debug
|
./bin/spc fetch --all --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./bin/spc build openssl,pcntl --build-all --enable-zts
|
||||||
|
```
|
||||||
|
|
||||||
|
Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary.
|
||||||
|
|
||||||
### php-cli Usage
|
### php-cli Usage
|
||||||
|
|
||||||
> php-cli is a single static binary, you can use it like normal php installed on your system.
|
> php-cli is a single static binary, you can use it like normal php installed on your system.
|
||||||
@@ -209,6 +215,10 @@ The basic principles for contributing are as follows:
|
|||||||
camelCase and underscore formats should be followed, and mixing within the same module is prohibited.
|
camelCase and underscore formats should be followed, and mixing within the same module is prohibited.
|
||||||
- When compiling external libraries and creating patches, compatibility with different operating systems should be considered.
|
- When compiling external libraries and creating patches, compatibility with different operating systems should be considered.
|
||||||
|
|
||||||
|
## Sponsor this project
|
||||||
|
|
||||||
|
You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md).
|
||||||
|
|
||||||
## Open-Source License
|
## Open-Source License
|
||||||
|
|
||||||
This project is based on the tradition of using the MIT License for old versions,
|
This project is based on the tradition of using the MIT License for old versions,
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -12,8 +12,6 @@ If you are using English, see [English README](README-en.md).
|
|||||||
|
|
||||||
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
<img width="600" alt="截屏2023-05-02 15 52 33" src="https://user-images.githubusercontent.com/20330940/235610318-2ef4e3f1-278b-4ca4-99f4-b38120efc395.png">
|
||||||
|
|
||||||
> 此分支为重构的新版,如果你在找纯 Bash 编写的旧版本,请到 [bash-version 分支](https://github.com/crazywhalecc/static-php-cli/tree/bash-version)。
|
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
[](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml)
|
||||||
@@ -125,6 +123,14 @@ chmod +x bin/spc
|
|||||||
./bin/spc fetch --all --debug
|
./bin/spc fetch --all --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
|
此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本(ZTS),只需添加参数 `--enable-zts` 即可。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./bin/spc build openssl,pcntl --build-all --enable-zts
|
||||||
|
```
|
||||||
|
|
||||||
|
同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。
|
||||||
|
|
||||||
### 使用 php-cli
|
### 使用 php-cli
|
||||||
|
|
||||||
> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。
|
> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。
|
||||||
@@ -194,6 +200,10 @@ cat micro.sfx code.php > single-app && chmod +x single-app
|
|||||||
|
|
||||||
另外,添加新扩展的贡献方式,可以参考下方 `进阶`。
|
另外,添加新扩展的贡献方式,可以参考下方 `进阶`。
|
||||||
|
|
||||||
|
## 赞助本项目
|
||||||
|
|
||||||
|
你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。
|
||||||
|
|
||||||
## 开源协议
|
## 开源协议
|
||||||
|
|
||||||
本项目依据旧版本惯例采用 MIT License 开源,自身的部分代码引用或修改自以下项目:
|
本项目依据旧版本惯例采用 MIT License 开源,自身的部分代码引用或修改自以下项目:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
|
|||||||
__PROJECT__=$(cd ${__DIR__}/../ && pwd)
|
__PROJECT__=$(cd ${__DIR__}/../ && pwd)
|
||||||
|
|
||||||
# set download dir
|
# set download dir
|
||||||
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.5-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||||
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||||
|
|
||||||
# use china mirror
|
# use china mirror
|
||||||
@@ -46,7 +46,7 @@ done
|
|||||||
|
|
||||||
case "$mirror" in
|
case "$mirror" in
|
||||||
china)
|
china)
|
||||||
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.5-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||||
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
__COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,14 @@
|
|||||||
"mongodb": {
|
"mongodb": {
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "mongodb",
|
"source": "mongodb",
|
||||||
"arg-type": "custom"
|
"arg-type": "custom",
|
||||||
|
"lib-depends": [
|
||||||
|
"zstd"
|
||||||
|
],
|
||||||
|
"lib-suggests": [
|
||||||
|
"icu",
|
||||||
|
"openssl"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"mysqli": {
|
"mysqli": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
@@ -421,4 +428,4 @@
|
|||||||
"zstd"
|
"zstd"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
```bash
|
```bash
|
||||||
|
|
||||||
# 启动 debian 11 容器环境
|
# 启动 debian 11 容器环境
|
||||||
sh quickstart/linux/x86_64/run-debian-11-container.sh
|
sh quickstart/linux/run-debian-11-container.sh
|
||||||
|
|
||||||
# 进入容器
|
# 进入容器
|
||||||
sh quickstart/linux/x86_64/connection-static-php-cli.sh
|
sh quickstart/linux/connection-static-php-cli.sh
|
||||||
|
|
||||||
# 准备构建基础软件
|
# 准备构建基础软件
|
||||||
sh quickstart/linux/x86_64/debian-11-init.sh
|
sh quickstart/linux/debian-11-init.sh
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -23,12 +23,12 @@ sh quickstart/linux/x86_64/debian-11-init.sh
|
|||||||
```bash
|
```bash
|
||||||
|
|
||||||
# 启动 alpine 容器环境
|
# 启动 alpine 容器环境
|
||||||
sh quickstart/linux/x86_64/run-alpine-3.16-container.sh
|
sh quickstart/linux/run-alpine-3.16-container.sh
|
||||||
|
|
||||||
# 进入容器
|
# 进入容器
|
||||||
sh sh quickstart/linux/x86_64/connection-static-php-cli.sh
|
sh sh quickstart/linux/connection-static-php-cli.sh
|
||||||
|
|
||||||
# 准备构建基础软件
|
# 准备构建基础软件
|
||||||
sh quickstart/linux/x86_64/alpine-3.16-init.sh
|
sh quickstart/linux/alpine-3.16-init.sh
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -36,3 +36,5 @@ esac
|
|||||||
apk update
|
apk update
|
||||||
|
|
||||||
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils
|
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils
|
||||||
|
apk add bash p7zip zip unzip flex pkgconf ca-certificates
|
||||||
|
apk add wget git curl
|
||||||
@@ -36,7 +36,6 @@ esac
|
|||||||
apt update -y
|
apt update -y
|
||||||
apt install -y git curl wget ca-certificates
|
apt install -y git curl wget ca-certificates
|
||||||
apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext coreutils lzip zip unzip
|
apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext coreutils lzip zip unzip
|
||||||
apt install -y pkg-config bzip2 flex
|
apt install -y pkg-config bzip2 flex p7zip
|
||||||
apt install -y musl-tools g++
|
apt install -y musl-tools g++
|
||||||
apt install -y clang
|
apt install -y clang
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ __DIR__=$(
|
|||||||
pwd
|
pwd
|
||||||
)
|
)
|
||||||
__PROJECT__=$(
|
__PROJECT__=$(
|
||||||
cd ${__DIR__}/../../../
|
cd ${__DIR__}/../../
|
||||||
pwd
|
pwd
|
||||||
)
|
)
|
||||||
cd ${__DIR__}
|
cd ${__DIR__}
|
||||||
@@ -6,7 +6,7 @@ __DIR__=$(
|
|||||||
pwd
|
pwd
|
||||||
)
|
)
|
||||||
__PROJECT__=$(
|
__PROJECT__=$(
|
||||||
cd ${__DIR__}/../../../
|
cd ${__DIR__}/../../
|
||||||
pwd
|
pwd
|
||||||
)
|
)
|
||||||
cd ${__DIR__}
|
cd ${__DIR__}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exu
|
|
||||||
__DIR__=$(
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
pwd
|
|
||||||
)
|
|
||||||
__PROJECT__=$(
|
|
||||||
cd ${__DIR__}/../../../
|
|
||||||
pwd
|
|
||||||
)
|
|
||||||
cd ${__PROJECT__}
|
|
||||||
|
|
||||||
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
|
||||||
|
|
||||||
chmod +x bin/spc
|
|
||||||
|
|
||||||
./bin/spc fetch --all --debug
|
|
||||||
|
|
||||||
./bin/spc list-ext
|
|
||||||
|
|
||||||
|
|
||||||
#./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=gcc --cxx=g++ --debug
|
|
||||||
|
|
||||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exu
|
|
||||||
__DIR__=$(
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
pwd
|
|
||||||
)
|
|
||||||
__PROJECT__=$(
|
|
||||||
cd ${__DIR__}/../../../
|
|
||||||
pwd
|
|
||||||
)
|
|
||||||
cd ${__PROJECT__}
|
|
||||||
|
|
||||||
export PATH=${__PROJECT__}/bin/runtime:$PATH
|
|
||||||
|
|
||||||
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
|
||||||
|
|
||||||
chmod +x bin/spc
|
|
||||||
|
|
||||||
./bin/spc fetch --all --debug
|
|
||||||
|
|
||||||
./bin/spc list-ext
|
|
||||||
|
|
||||||
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo,pdo_sqlite,ftp,curl" --cc=clang --cxx=clang++ --debug
|
|
||||||
52
quickstart/prepare.sh
Normal file
52
quickstart/prepare.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -exu
|
||||||
|
__DIR__=$(
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
pwd
|
||||||
|
)
|
||||||
|
__PROJECT__=$(
|
||||||
|
cd ${__DIR__}/../
|
||||||
|
pwd
|
||||||
|
)
|
||||||
|
cd ${__PROJECT__}
|
||||||
|
|
||||||
|
OS=$(uname -s)
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
if [[ $OS = "Linux" && -f /etc/os-release ]]; then
|
||||||
|
OS_NAME=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}')
|
||||||
|
# debian ubuntu alpine
|
||||||
|
fi
|
||||||
|
|
||||||
|
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||||
|
|
||||||
|
chmod +x bin/spc
|
||||||
|
|
||||||
|
./bin/spc fetch --all --debug
|
||||||
|
|
||||||
|
./bin/spc list-ext
|
||||||
|
|
||||||
|
EXTENSIONS="calendar,ctype,exif,fileinfo,filter,ftp"
|
||||||
|
EXTENSIONS="${EXTENSIONS},session,tokenizer"
|
||||||
|
EXTENSIONS="${EXTENSIONS},phar,posix"
|
||||||
|
EXTENSIONS="${EXTENSIONS},iconv"
|
||||||
|
EXTENSIONS="${EXTENSIONS},xml,dom,simplexml,xmlwriter,xmlreader"
|
||||||
|
EXTENSIONS="${EXTENSIONS},phar,posix"
|
||||||
|
EXTENSIONS="${EXTENSIONS},soap"
|
||||||
|
EXTENSIONS="${EXTENSIONS},mbstring,mbregex"
|
||||||
|
EXTENSIONS="${EXTENSIONS},openssl"
|
||||||
|
EXTENSIONS="${EXTENSIONS},sockets,gmp,bcmath"
|
||||||
|
EXTENSIONS="${EXTENSIONS},pcntl"
|
||||||
|
EXTENSIONS="${EXTENSIONS},curl"
|
||||||
|
EXTENSIONS="${EXTENSIONS},zlib,zip,bz2"
|
||||||
|
EXTENSIONS="${EXTENSIONS},gd"
|
||||||
|
EXTENSIONS="${EXTENSIONS},redis"
|
||||||
|
EXTENSIONS="${EXTENSIONS},pdo,pdo_mysql,pdo_sqlite"
|
||||||
|
EXTENSIONS="${EXTENSIONS},mysqlnd,sqlite3"
|
||||||
|
EXTENSIONS="${EXTENSIONS},mongodb"
|
||||||
|
# EXTENSIONS="${EXTENSIONS},swoole"
|
||||||
|
EXTENSIONS="${EXTENSIONS},swow"
|
||||||
|
|
||||||
|
./bin/spc build "${EXTENSIONS}" --build-cli --cc=clang --cxx=clang++ --debug
|
||||||
|
# ./bin/spc build "${EXTENSIONS}" --build-cli --cc=gcc --cxx=g++ --debug
|
||||||
@@ -12,6 +12,17 @@ class mongodb extends Extension
|
|||||||
{
|
{
|
||||||
public function getUnixConfigureArg(): string
|
public function getUnixConfigureArg(): string
|
||||||
{
|
{
|
||||||
return '--enable-mongodb --without-mongodb-sasl';
|
$arg = ' --enable-mongodb ';
|
||||||
|
$arg .= ' --with-mongodb-system-libs=no ';
|
||||||
|
$arg .= ' --with-mongodb-sasl=no ';
|
||||||
|
if ($this->builder->getLib('openssl')) {
|
||||||
|
$arg .= '--with-mongodb-ssl=openssl';
|
||||||
|
}
|
||||||
|
if ($this->builder->getLib('icu')) {
|
||||||
|
$arg .= ' --with-mongodb-icu=yes ';
|
||||||
|
} else {
|
||||||
|
$arg .= ' --with-mongodb-icu=no ';
|
||||||
|
}
|
||||||
|
return $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user