Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Runtime adapters

未关闭
#1 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
docker, php, vscode, wordpress

调研方向

首先,将列出的运行时和关注点分开:缓存、网络调用、子进程、进度、文件系统和挂载。阅读链接的 issue 46 和 WordPress Playground issue 1026;payload 没有列出任何实现文件或测试,因此第一个里程碑是在定义什么算完成之前,先就范围和运行时边界达成一致。

由索引模型根据 Issue 内容生成。

描述

Architecture

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 libcurl or fopen("https://")
  • In Playground, we can only rely on fetch(). We can't open raw TCP sockets so fopen("https://") and libcurl cannot be easily used.
  • In VS Code, we can open raw TCP sockets so fopen("https://"), but libcurl isn't since Playground doesn't support it yet.
Spawning child processes

Blueprint steps, wp-cli, phpunit, and other tools will often spawn child processes.

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 its widths and innerText
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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

WordPress/php-toolkit 的其他 Issue

查看 WordPress/php-toolkit 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。