Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix Chinese docs to make it more readable #615

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ docker run -v $PWD:/app/public \

访问 `https://localhost`, 并享受吧!

> [!提示]
> [!TIP]
>
> 不要尝试使用 `https://127.0.0.1`。使用 `localhost` 并接受自签名证书。
> 使用 [`SERVER_NAME` 环境变量](config.md#环境变量) 更改要使用的域。

### 独立二进制

如果您不想使用 Docker,我们为 Linux 和 macOS 提供独立的 FrankenPHP 二进制文件
包含 [PHP 8.3](https://www.php.net/releases/8.3/en.php) 和最流行的 PHP 扩展:[下载 FrankenPHP](https://github.com/dunglas/frankenphp/releases)
,其中包含 [PHP 8.3](https://www.php.net/releases/8.3/en.php) 和最流行的 PHP 扩展:[下载 FrankenPHP](https://github.com/dunglas/frankenphp/releases)

若要启动当前目录的内容,请运行:

Expand All @@ -61,7 +61,7 @@ docker run -v $PWD:/app/public \
* [从源代码编译](compile.md)
* [Laravel 集成](laravel.md)
* [已知问题](known-issues.md)
* [演示应用程序 (Symfony) 和基准测试](https://github.com/dunglas/frankenphp-demo)
* [演示应用程序 (Symfony) 和性能测试](https://github.com/dunglas/frankenphp-demo)
* [Go 库文档](https://pkg.go.dev/github.com/dunglas/frankenphp)
* [贡献和调试](https://frankenphp.dev/docs/contributing/)

Expand Down
24 changes: 11 additions & 13 deletions docs/cn/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
本文档解释了如何创建一个 FrankenPHP 构建,它将 PHP 加载为一个动态库。
这是推荐的方法。

或者,[创建静态构建](static.md)也是可能的
或者,你也可以 [编译静态版本](static.md)。

## 安装 PHP

FrankenPHP PHP 8.2 及更高版本兼容
FrankenPHP 支持 PHP 8.2 及更高版本

首先,[获取PHP的源代码](https://www.php.net/downloads.php)并提取它们:
首先,[获取 PHP 源代码](https://www.php.net/downloads.php) 并提取它们:

```console
tar xf php-*
Expand Down Expand Up @@ -37,15 +37,14 @@ sudo make install

### Mac

使用 [Homebrew](https://brew.sh/) 包管理器安装
`libiconv`, `bison`, `re2c` 和 `pkg-config`:
使用 [Homebrew](https://brew.sh/) 包管理器安装 `libiconv`、`bison`、`re2c` 和 `pkg-config`:

```console
brew install libiconv bison re2c pkg-config
echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc
```

然后运行配置脚本
然后运行 `./configure` 脚本

```console
./configure \
Expand All @@ -58,8 +57,7 @@ echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc
--with-iconv=/opt/homebrew/opt/libiconv/
```

这些标志是必需的,但您可以添加其他标志(例如额外的扩展)
如果需要。
这些参数是必需的,但你也可以添加其他编译参数(例如额外的扩展)。

最后,编译并安装 PHP:

Expand All @@ -80,7 +78,7 @@ CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-c

### 使用 xcaddy

或者,使用 [xcaddy](https://github.com/caddyserver/xcaddy) [自定义 Caddy 模块](https://caddyserver.com/docs/modules/) 编译 FrankenPHP:
你可以使用 [xcaddy](https://github.com/caddyserver/xcaddy) 来编译 [自定义 Caddy 模块](https://caddyserver.com/docs/modules/) FrankenPHP:

```console
CGO_ENABLED=1 \
Expand All @@ -93,12 +91,12 @@ xcaddy build \
# Add extra Caddy modules here
```

> [!提示]
> [!TIP]
>
> 如果您使用的是 musl libc(Alpine Linux 上的默认值)和 Symfony,
> 如果你的系统基于 musl libcAlpine Linux 上默认使用)并搭配 Symfony 使用
> 您可能需要增加默认堆栈大小。
> 否则,您可能会收到如下错误 `PHP Fatal error: Maximum call stack size of 83360 bytes reached during compilation. Try splitting expression`
>
> 为此,请将 `XCADDY_GO_BUILD_FLAGS` 环境变量更改为类似
> 请将 `XCADDY_GO_BUILD_FLAGS` 环境变量更改为如下类似的值
> `XCADDY_GO_BUILD_FLAGS=$'-ldflags "-w -s -extldflags \'-Wl,-z,stack-size=0x80000\'"'`
> (根据您的应用需求更改堆栈大小的值)
> (根据您的应用需求更改堆栈大小)
32 changes: 16 additions & 16 deletions docs/cn/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ FrankenPHP,Caddy 以及 Mercure 和 Vulcain 模块可以使用 [Caddy 支持

您也可以像往常一样使用 `php.ini` 配置 PHP。

在 Docker 镜像中,`php.ini` 文件不存在,您可以手动创建它或 `复制`
在 Docker 镜像中,默认不存在 `php.ini`,您可以手动创建它或从官方模板中复制

```dockerfile
FROM dunglas/frankenphp

# 开发:
RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini

# 还是生产:
# 生产:
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
```

## Caddyfile 配置

要注册 FrankenPHP 执行器,必须设置 `frankenphp` [全局选项](https://caddyserver.com/docs/caddyfile/concepts#global-options),然后可以在站点块中使用 `php_server` 或 `php` [HTTP 指令](https://caddyserver.com/docs/caddyfile/concepts#directives)来为您的 PHP 应用程序提供服务。
要注册 FrankenPHP 执行器,必须设置 `frankenphp` [全局选项](https://caddyserver.com/docs/caddyfile/concepts#global-options),然后可以在站点块中使用 `php_server` 或 `php` [HTTP 指令](https://caddyserver.com/docs/caddyfile/concepts#directives) 来为您的 PHP 应用程序提供服务。

极小示例
最小示例

```caddyfile
{
Expand All @@ -33,14 +33,14 @@ RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
}

localhost {
# 启用压缩(可选)
# 启用压缩(可选)
encode zstd br gzip
# 执行当前目录中的 PHP 文件并提供资产
php_server
}
```

或者,可以在全局选项下指定要创建的线程数和要从服务器启动的 [worker scripts](worker.md)。
或者,可以在全局选项下指定要创建的线程数和要从服务器启动的 [worker 脚本](worker.md)。

```caddyfile
{
Expand Down Expand Up @@ -69,7 +69,7 @@ localhost {
# ...
```

如果在同一服务器上提供多个应用,还可以定义多个 worker:
如果在同一服务器上运行多个应用,还可以定义多个 worker:

```caddyfile
{
Expand All @@ -88,11 +88,11 @@ other.example.com {
root * /path/to/other/public
php_server
}
...
# ...
```

使用 `php_server` 指令通常是您需要的
但是,如果您需要完全控制,则可以使用较低级别的 `php` 指令:
通常你只需要 `php_server` 指令
但如果要完全控制,则可以使用较低级别的 `php` 指令:

使用 `php_server` 指令等效于以下配置:

Expand All @@ -104,7 +104,7 @@ route {
not path */
}
redir @canonicalPath {path}/ 308
# 如果请求的文件不存在,请尝试 index 文件
# 如果请求的文件不存在,则尝试 index 文件
@indexFiles file {
try_files {path} {path}/index.php index.php
split_path .php
Expand All @@ -121,10 +121,10 @@ route {

```caddyfile
php_server [<matcher>] {
root <directory> # 设置站点的根文件夹。默认值:`root` 指令。
split_path <delim...> # 设置用于将 URI 拆分为两部分的子字符串。第一个匹配的子字符串将用于从路径中拆分“路径信息”。第一个部分以匹配的子字符串为后缀,并将假定为实际资源(CGI 脚本)名称。第二部分将设置为PATH_INFO,供 脚本使用。默认值:`.php`
resolve_root_symlink # 允许通过计算符号链接(如果存在)将 `根` 目录解析为其实际值
env <key> <value> # 将额外的环境变量设置为给定值。可以为多个环境变量多次指定
root <directory> # 设置站点的根目录。默认值:`root` 指令。
split_path <delim...> # 设置用于将 URI 拆分为两部分的子字符串。第一个匹配的子字符串将用于从路径中拆分“路径信息”。第一个部分以匹配的子字符串为后缀,并将假定为实际资源(CGI 脚本)名称。第二部分将设置为PATH_INFO,供脚本使用。默认值:`.php`
resolve_root_symlink false # 禁用将 `root` 目录在符号链接时将其解析为实际值(默认启用)
env <key> <value> # 设置额外的环境变量,可以设置多个环境变量
}
```

Expand All @@ -138,7 +138,7 @@ php_server [<matcher>] {

## PHP 配置

要加载[其他PHP配置文件](https://www.php.net/manual/en/configuration.file.php#configuration.file.scan),
要加载 [其他 PHP INI 配置文件](https://www.php.net/manual/en/configuration.file.php#configuration.file.scan),
可以使用 `PHP_INI_SCAN_DIR` 环境变量。
设置后,PHP 将加载给定目录中存在 `.ini` 扩展名的所有文件。

Expand Down
34 changes: 17 additions & 17 deletions docs/cn/docker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 构建自定义 Docker 镜像

[FrankenPHP Docker 镜像](https://hub.docker.com/r/dunglas/frankenphp)基于[官方PHP镜像](https://hub.docker.com/_/php/)。Alpine Linux 和 Debian 变体适用于流行的架构。提供了 PHP 8.2 和 PHP 8.3 的变体。[浏览标签](https://hub.docker.com/r/dunglas/frankenphp/tags)。
[FrankenPHP Docker 镜像](https://hub.docker.com/r/dunglas/frankenphp) 基于 [官方 PHP 镜像](https://hub.docker.com/_/php/)。
Alpine Linux 和 Debian 衍生版适用于常见的处理器架构,且支持 PHP 8.2 和 PHP 8.3。[查看 Tags](https://hub.docker.com/r/dunglas/frankenphp/tags)。

## 如何使用镜像

Expand All @@ -12,17 +13,17 @@ FROM dunglas/frankenphp
COPY . /app/public
```

然后,运行以下命令以构建并运行 Docker 镜像:
然后运行以下命令以构建并运行 Docker 镜像:

```console
docker build -t my-php-app .
docker run -it --rm --name my-running-app my-php-app
```

## 如何安装更多PHP扩展
## 如何安装更多 PHP 扩展

[`docker-php-extension-installer`](https://github.com/mlocati/docker-php-extension-installer)脚本在基础镜像中提供。
添加额外的PHP扩展很简单
[`docker-php-extension-installer`](https://github.com/mlocati/docker-php-extension-installer) 脚本在基础镜像中提供。
添加额外的 PHP 扩展很简单

```dockerfile
FROM dunglas/frankenphp
Expand Down Expand Up @@ -54,7 +55,7 @@ RUN xcaddy build \
--output /usr/local/bin/frankenphp \
--with github.com/dunglas/frankenphp=./ \
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
# Mercure 和 Vulcain 包含在官方版本中,但请随意删除它们
# Mercure 和 Vulcain 包含在官方版本中,如果不需要你可以删除它们
--with github.com/dunglas/mercure/caddy \
--with github.com/dunglas/vulcain/caddy
# 在此处添加额外的 Caddy 模块
Expand All @@ -66,11 +67,11 @@ COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
```

FrankenPHP 提供的 `builder` 镜像包含 libphp 的编译版本。
[构建器图像](https://hub.docker.com/r/dunglas/frankenphp/tags?name=builder) 适用于所有版本的 FrankenPHP 和 PHP,包括 Alpine 和 Debian。
[用于构建的镜像](https://hub.docker.com/r/dunglas/frankenphp/tags?name=builder) 适用于所有版本的 FrankenPHP 和 PHP,包括 Alpine 和 Debian。

> [!提示]
> [!TIP]
>
> 如果您使用的是 Alpine Linux Symfony,
> 如果你的系统基于 musl libc(Alpine Linux 上默认使用)并搭配 Symfony 使用
> 您可能需要 [增加默认堆栈大小](compile.md#使用-xcaddy)。

## 默认启用 worker 模式
Expand All @@ -85,15 +86,15 @@ FROM dunglas/frankenphp
ENV FRANKENPHP_CONFIG="worker ./public/index.php"
```

## 在开发中使用 Volume
## 开发挂载宿主机目录

要使用 FrankenPHP 轻松开发,请从包含应用程序源代码的主机挂载目录作为 Docker 容器中的 volume:

```console
docker run -v $PWD:/app/public -p 80:80 -p 443:443 -p 443:443/udp --tty my-php-app
```

> [!提示]
> [!TIP]
>
> `--tty` 选项允许使用清晰可读的日志,而不是 JSON 日志。

Expand All @@ -120,7 +121,7 @@ services:
# 在生产环境中注释以下行,它允许在 dev 中使用清晰可读日志
tty: true

# Caddy 证书和配置所需的 volumes
# Caddy 证书和配置所需的挂载目录
volumes:
caddy_data:
caddy_config:
Expand Down Expand Up @@ -153,12 +154,11 @@ USER ${USER}
Docker 镜像会按照以下条件更新:

* 发布新的版本后
* 每天的 4am UTC 检查如果有新的PHP镜像可用
* 每日 4:00(UTC 时间)检查新的 PHP 镜像

## 开发版本

可在此docker[`dunglas/frankenphp-dev`](https://hub.docker.com/repository/docker/dunglas/frankenphp-dev)仓库路径获取开发版本
每次在GitHub仓库的主分支有了新的commit都会触发一个新的build
可在此 [`dunglas/frankenphp-dev`](https://hub.docker.com/repository/docker/dunglas/frankenphp-dev) 仓库获取开发版本
每次在 GitHub 仓库的主分支有新的 commit 都会触发一次新的 build

'latest*' tag 指向最新的`main`分支。
也支持 'sha-<git-commit-hash>' 的tag格式。
`latest*` tag 指向最新的 `main` 分支,且同样支持 `sha-<git-commit-hash>` 的 tag。
2 changes: 1 addition & 1 deletion docs/cn/early-hints.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 早期提示

FrankenPHP 原生支持 [103 Early Hints 状态代码](https://developer.chrome.com/blog/early-hints/)。
FrankenPHP 原生支持 [103 Early Hints 状态码](https://developer.chrome.com/blog/early-hints/)。
使用早期提示可以将网页的加载时间缩短 30%。

```php
Expand Down
Loading
Loading