Runtime adapters
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
调研方向
首先,将列出的运行时和关注点分开:缓存、网络调用、子进程、进度、文件系统和挂载。阅读链接的 issue 46 和 WordPress Playground issue 1026;payload 没有列出任何实现文件或测试,因此第一个里程碑是在定义什么算完成之前,先就范围和运行时边界达成一致。
由索引模型根据 Issue 内容生成。
描述
Blueprints should support at least the following runtimes:
- wp-cli
- Docker
- wp-now
- Playground
- Native PHP CLI
- VS Code extension
Runtime-specific features
Caching the downloads
Blueprints shouldn't download the same 10MB WordPress.zip twice. Let's make sure we cache the downloads and invalidate the entries as new versions of Core and Plugins are released.
- In native PHP CLI, we can cache in the filesystem, e.g.
~/.wp/. Ideally, this would take HTTP headers into consideration. - In Playground, we can rely on HTTP cache built into
fetch(). In addition, we could cache at the service worker level. - In VS Code, there's a caching API AFAIR.
- In Docker, we could use the docker build layers for caching.
Network calls
- In native PHP CLI, we can use
libcurlorfopen("https://") - In Playground, we can only rely on
fetch(). We can't open raw TCP sockets sofopen("https://")andlibcurlcannot be easily used. - In VS Code, we can open raw TCP sockets so
fopen("https://"), butlibcurlisn't since Playground doesn't support it yet.
Spawning child processes
Blueprint steps, wp-cli, phpunit, and other tools will often spawn child processes.
- In wp-now PHP and native PHP, we can rely on
proc_open - In Playground, we need a custom spawn handler implemented in JavaScript
Reporting progress
- In any CLI, we should display an ASCII progress bar.
- With Docker as a backend, we should report the build progress somehow.
- In Playground, progress bar is a
<div>that needs to change itswidthsandinnerText
Filesystem interactions
I'd love to avoid abstract the filesystem and just use the regular PHP functions like copy() and fread()
Local mounts
It may useful to support mounting directories
- In the browser, we would either bale out (with a warning?) or mount an OPFS directory, whether that's page-specific or a local directory handle
- In wp-now and Docker, we can mount directories in the runtime without changing anything on the disk
- In Native PHP we could use symlinks
Technical implementation
Dependency injection
Let's explore the dependency injection pattern. Pimple is a tiny service container we can use to plug-in runtime-specific implementations:
$container = new Container();
switch ( $runtime ) {
case self::RUNTIME_NATIVE:
$container['downloads_cache'] = function ( $c ) {
return new FileCache();
};
$container['http_client'] = function ( $c ) {
return HttpClient::create();
};
$container['progress_reporter'] = function ( $c ) {
return function ( ProgressEvent $event ) {
echo $event->url . ' ' . $event->downloadedBytes . '/' . $event->totalBytes . " \r";
};
};
break;
case self::RUNTIME_PLAYGROUND:
$container['downloads_cache'] = function ( $c ) {
// @TODO
};
$container['http_client'] = function ( $c ) {
// @TODO
};
$container['progress_reporter'] = function ( $c ) {
// @TODO
// post_message_to_js();
};
break;
Other ideas
What are other viable solutions to this problem?
- 主要语言
- PHP
- 星标
- 62
- 派生
- 23
- 平均合并
- 4 小时 12 分钟
- 30 天内合并 PR
- 1
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WordPress/php-toolkit 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
WordPress/php-toolkit#313 ·
-
难度 4/5 3-5 天 新手友好度 58/100
WordPress/php-toolkit#306 ·
-
WPCS compliance未关闭
难度 4/5 3-5 天 新手友好度 35/100
WordPress/php-toolkit#157 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 25/100
WordPress/php-toolkit#138 · 7 条评论 · 2 个 reaction ·
-
[Blueprints v2] Constraint the Blueprint bundle format可能已有人在做 @JanJakes 于 451 天前认领。 未关闭Blueprints enhancement
WordPress/php-toolkit#132 · 4 条评论 · 已指派 1 人 ·
查看 WordPress/php-toolkit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
MISP/misp-docker#478 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
glpi-project/glpi#26045 ·
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
Перевод устарел
难度 2/5 1-3 小时 新手友好度 82/100