Skip to content

Commit c3bed0f

Browse files
committed
Update README and docs
1 parent f5accf7 commit c3bed0f

File tree

21 files changed

+1164
-194
lines changed

21 files changed

+1164
-194
lines changed

.github/workflows/vitepress.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Docs Auto Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'docs/**'
8+
9+
jobs:
10+
build:
11+
name: Deploy docs
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout master
15+
uses: actions/checkout@v4
16+
17+
- uses: actions/setup-node@v3
18+
with:
19+
cache: 'npm'
20+
21+
- run: cd docs && npm install
22+
23+
- name: Build
24+
run: cd docs && npm run docs:build
25+
26+
- name: Deploy to GitHub Pages
27+
uses: peaceiris/actions-gh-pages@v3
28+
with:
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
publish_dir: docs/.vitepress/dist

README-zh.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# micro 自执行 SAPI
2+
3+
[![英文文档](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md)
4+
[![中文文档](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md)
5+
[![许可证](https://img.shields.io/badge/License-Apache--2.0-cyan.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
6+
7+
**micro** SAPI 让 PHP 可以自执行,允许你在没有安装 PHP 的情况下运行 php-cli 应用。
8+
9+
![](docs/public/images/micro.png)
10+
11+
-----------
12+
13+
micro 是 PHP 的一个 SAPI 模块,允许你创建自执行的 PHP 二进制文件。
14+
通过将 micro SAPI 二进制文件与你的 PHP 源代码或 PHAR 文件连接,
15+
你可以在不需要单独安装 PHP 的情况下运行 PHP 应用程序。
16+
17+
micro SAPI 的工作方式类似于内置的 CLI SAPI,你可以使用它运行几乎所有基于 CLI 的 PHP 应用程序。
18+
19+
## 快速开始
20+
21+
我们推荐使用 [static-php-cli](https://static-php.dev) 构建 micro SAPI,以便包含像 `pdo``openssl``mbstring` 等流行的扩展。
22+
23+
你可以先尝试由 static-php.dev 服务器托管的[预构建 micro SAPI 二进制文件](https://dl.static-php.dev/static-php-cli/common/)
24+
25+
| 平台 | 下载链接 |
26+
|----------------|----------------------------------------------------------------------------------------------------|
27+
| Linux x86_64 | [micro.sfx](https://dl.static-php.dev/static-php-cli/common/php-8.4.14-micro-linux-x86_64.tar.gz) |
28+
| Linux aarch64 | [micro.sfx](https://dl.static-php.dev/static-php-cli/common/php-8.4.14-micro-linux-aarch64.tar.gz) |
29+
| Windows x86_64 | [micro.sfx](https://dl.static-php.dev/static-php-cli/windows/spc-max/php-8.4.14-micro-win.zip) |
30+
| macOS x86_64 | [micro.sfx](https://dl.static-php.dev/static-php-cli/common/php-8.4.14-micro-macos-x86_64.tar.gz) |
31+
| macOS arm64 | [micro.sfx](https://dl.static-php.dev/static-php-cli/common/php-8.4.14-micro-macos-aarch64.tar.gz) |
32+
33+
然后准备你的 PHP 代码或 PHAR cli 应用归档文件,并将它们连接起来:
34+
35+
```php
36+
<?php // myapp.php
37+
echo "Hello, this is my awesome app." . PHP_EOL;
38+
```
39+
40+
```shell
41+
# 在 Linux/macOS 上:
42+
cat /path/to/micro.sfx myapp.php > myapp
43+
chmod +x ./myapp
44+
./myapp
45+
# 显示 "hello, this is my awesome app."
46+
47+
# 或在 Windows 上:
48+
COPY /b \path\to\micro.sfx + myapp.php myapp.exe
49+
.\myapp.exe
50+
# 显示 "hello, this is my awesome app."
51+
```
52+
53+
## 构建静态链接的 micro.sfx
54+
55+
由于我们需要将 micro.sfx 构建为独立且可移植的二进制文件,最好的方法是静态构建。
56+
这将确保它可以在大多数系统上运行,而不必担心缺少共享库。
57+
58+
你可以按照 static-php.dev 文档中的步骤构建自己的包含 micro SAPI 的静态 PHP 二进制文件:
59+
60+
1. 首先,按照[安装指南](https://static-php.dev/zh/guide/manual-build)下载并安装 static-php-cli。
61+
2. 接下来,使用 `spc` 命令构建包含 micro SAPI 的静态 PHP 二进制文件:
62+
63+
```bash
64+
# linux/macOS
65+
EXTENSIONS="bcmath,phar,openssl,mbstring"
66+
./spc doctor --auto-fix
67+
./spc download --for-extensions=$EXTENSIONS --with-php=8.4
68+
./spc build $EXTENSIONS --build-micro
69+
cp buildroot/bin/micro.sfx /path/to/your/micro.sfx
70+
71+
# windows (PowerShell)
72+
.\spc.exe doctor --auto-fix
73+
.\spc.exe download --for-extensions="bcmath,phar,openssl,mbstring" --with-php=8.4
74+
.\spc.exe build "bcmath,phar,openssl,mbstring" --build-micro
75+
copy .\buildroot\bin\micro.sfx \path\to\your\micro.sfx
76+
```
77+
78+
## 文档(WIP)
79+
80+
有关 micro SAPI 的更多详细信息,如动态构建 micro、构建多文件应用、更多配置方式等,请参阅 <https://micro.static-php.dev> 文档。
81+
82+
## 开源许可证
83+
84+
本项目采用 Apache-2.0 许可证。详情请参见 [LICENSE](LICENSE) 文件。
85+
86+
使用 static-php-cli 构建静态 PHP 时,生成的二进制文件可能包含其他开源组件。
87+
请参考 [static-php-cli LICENSE](https://github.com/crazywhalecc/static-php-cli#open-source-license) 说明。

0 commit comments

Comments
 (0)