update README

This commit is contained in:
crazywhalecc 2023-04-22 22:18:44 +08:00
parent 528ad1199a
commit 48f40b4304
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 59 additions and 11 deletions

View File

@ -37,7 +37,7 @@ Please first select the extension you want to compile based on the extension lis
### Supported Extensions
[Support Extension List](/ext-support.md)
[Supported Extension List](/ext-support.md)
### GitHub Actions Build
@ -56,14 +56,36 @@ If you enable `debug`, all logs will be output at build time, including compiled
### Manual Build
Clone repo first:
```bash
# Clone first
git clone https://github.com/crazywhalecc/static-php-cli.git
```
If you have not installed php on your system, you can download single-file php binary and composer first.
The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`.
```bash
cd static-php-cli
chmod +x bin/setup-runtime
./bin/setup-runtime
# Use this php runtime to run static-php-cli compiler
./bin/php bin/spc
# Use composer
./bin/php bin/composer
```
Basic usage for building php and micro with some extensions:
```bash
cd static-php-cli
composer update
chmod +x bin/spc
# Check system tool dependencies, and show instructions for fixing (TODO)
# ./spc doctor
# Check system tool dependencies, fix them automatically (only support macOS) (TODO: Linux distro support)
./bin/spc doctor
# fetch all libraries
./bin/spc fetch --all
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
@ -73,13 +95,14 @@ chmod +x bin/spc
You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2:
```bash
# Using PHP >= 8.0 is recommended, because 7.4 cannot use phpmicro
./bin/spc fetch --with-php=8.2 --all
```
If anything goes wrong, use `--debug` option to display full terminal output:
```bash
./bin/spc build openssl --debug
./bin/spc build openssl,pcntl,mbstring --debug
./bin/spc fetch --all --debug
```
@ -100,8 +123,9 @@ This file will be located in the directory `source/php-src/sapi/cli/`, simply co
### micro.sfx Usage
> phpmicro is a Self-Extracted Executable SAPI module, provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
> This project is integrated with it.
> phpmicro is a Self-Extracted Executable SAPI module,
> provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro).
> It can put php runtime and your source code together.
When using the parameter `--build-all` or `--build-micro`,
the final compilation result will output a file named `./micro.sfx`,

View File

@ -52,14 +52,37 @@ If you are using English, see [English README](README-en.md).
### 手动构建
先克隆本项目:
```bash
git clone https://github.com/crazywhalecc/static-php-cli.git
```
如果你本机没有安装 PHP你可以通过命令下载静态编译好的 php-cli 和 Composer。
下载的 php 和 Composer 将保存为 `bin/php``bin/composer`
```bash
cd static-php-cli
chmod +x bin/setup-runtime
./bin/setup-runtime
# 使用独立的 php 运行 static-php-cli
./bin/php bin/spc
# 使用 composer
./bin/php bin/composer
```
下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法:
```bash
# 克隆本项目
git clone https://github.com/crazywhalecc/static-php-cli.git
cd static-php-cli
composer update
chmod +x bin/spc
# 检查环境依赖并根据提示的命令安装缺失的编译工具TODO
# ./bin/spc doctor
# 检查环境依赖,并根据提示的命令安装缺失的编译工具(目前仅支持 macOSLinux 后续会支持
./bin/spc doctor
# 拉取所有依赖库
./bin/spc fetch --all
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
@ -69,13 +92,14 @@ chmod +x bin/spc
你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.4 ~ 8.2
```bash
# 优先考虑使用 >= 8.0 的 PHP 版本
./bin/spc fetch --with-php=8.2 --all
```
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
```bash
./bin/spc build openssl --debug
./bin/spc build openssl,pcntl,mbstring --debug
./bin/spc fetch --all --debug
```