mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 14:55:39 +08:00
Refactor documentation structure and add new artifact model guide
This commit is contained in:
8
docs/zh/develop/extending/custom-artifact.md
Normal file
8
docs/zh/develop/extending/custom-artifact.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 自定义 Artifact
|
||||
|
||||
<!-- TODO: 介绍如何在 src/Package/Artifact/ 下实现自定义下载类。
|
||||
说明 type: custom 的适用场景(如需鉴权、非标准压缩包格式等)。
|
||||
涵盖:类的位置与命名规范、方法签名(默认下载方法与 func 分发)、
|
||||
读取配置字段、返回解压后的源码路径、
|
||||
通过 spc.registry.yml 的 artifact psr-4 映射注册类。
|
||||
提供带注释的完整代码示例。 -->
|
||||
8
docs/zh/develop/extending/index.md
Normal file
8
docs/zh/develop/extending/index.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 扩展 StaticPHP
|
||||
|
||||
<!-- TODO: 介绍三种扩展方式:
|
||||
1. 贡献到 core —— 直接修改 src/Package/ 和 config/pkg/。
|
||||
2. 外部 Registry —— 通过 SPC_REGISTRIES 环境变量指向自定义 spc.registry.yml。
|
||||
3. Vendor 模式 —— 将类和配置打包为 Composer 库(composer require)。
|
||||
说明各方式的适用场景。给出最小端到端示例:
|
||||
一个 Library 类 + 一个配置 YAML + 一个 spc.registry.yml + 运行 spc。 -->
|
||||
@@ -12,7 +12,7 @@ StaticPHP 本身携带一个内置的核心注册表(`core`),其中包含
|
||||
外部 Registry 只能定义 `core` 中尚不存在的新包,不能覆盖或修改核心注册表中已有的定义。根据你的需求,有以下三种方式来扩展或修改 StaticPHP 的构建能力:
|
||||
|
||||
- **修改 `core` 注册表**:直接修改 `src/Package` 和 `config/pkg/` 下的文件,适用于希望将改动合并回 StaticPHP 主线的情况。请先阅读 [贡献指南](../contributing/) 中关于贡献新包的部分,再提交 PR。
|
||||
- **Vendor 模式**:将自定义包封装为一个独立的子注册表,以 Composer 包的形式分发,适用于需要私有包或希望以库的形式复用构建逻辑的场景。详见 [Vendor 模式](./vendor-mode/)。
|
||||
- **Vendor 模式**:将自定义包封装为一个独立的子注册表,以 Composer 包的形式分发,适用于需要私有包或希望以库的形式复用构建逻辑的场景。详见 [扩展 StaticPHP](./extending/)。
|
||||
- **外部注册表(`SPC_REGISTRIES`)**:通过环境变量 `SPC_REGISTRIES` 指定一个或多个外部注册表文件的路径,StaticPHP 会在启动时加载它们。适用于临时扩展或不便打包为 Composer 包的场景,与其他包管理器的外部源机制类似。
|
||||
|
||||
## Registry 定义文件
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# 资源模块
|
||||
|
||||
<!-- TODO: 从 v2 source-module.md 迁移并更新。
|
||||
记录 v3 source 类型:url、ghrel、ghtar、ghtagtar、git、pecl(新增)、filelist、custom。
|
||||
per-package YAML source 块格式。并行下载(--parallel N)。 -->
|
||||
@@ -1,6 +0,0 @@
|
||||
# Vendor 模式
|
||||
|
||||
<!-- TODO: Vendor 模式是什么,适用场景。
|
||||
安装:`composer require crazywhalecc/static-php-cli`。
|
||||
注册指向自定义包类的外部 Registry。
|
||||
最小工作示例:一个 Library 类 + 一个配置 YAML + 运行 spc。 -->
|
||||
Reference in New Issue
Block a user