wp-php-toolkit/blueprints
Composer 安装命令:
composer require wp-php-toolkit/blueprints
包简介
Blueprints component for WordPress.
关键字:
README 文档
README
| slug | blueprints | |||
|---|---|---|---|---|
| title | Blueprints | |||
| install | wp-php-toolkit/blueprints | |||
| see_also |
|
Declarative WordPress site provisioning. Write a Blueprint JSON document for plugins, options, content, and setup steps; let the runner execute it.
Why this exists
A WordPress environment is more than a database dump. It can require a specific core version, plugins, themes, site options, uploaded files, content, and setup steps. Rebuilding that by hand makes demos, tests, bug reports, workshops, and CI fixtures drift over time.
The Blueprints component treats site setup as data. A blueprint JSON document describes the desired steps, and the runner applies them to either a new WordPress install or an existing one. The validator exists because user-authored JSON needs clear, path-specific errors rather than generic schema failures.
RunnerConfiguration separates the web root from the WordPress core directory, since real hosts often put them in different places. Both paths are explicit on the runner, never inferred.
Blueprints can create a new WordPress install (download core, set up the database, apply steps) or apply to an existing site. Creating a fresh install needs filesystem access this in-browser runtime doesn't have, so the runnable snippets focus on APPLY_TO_EXISTING_SITE.
Configure a runner for an existing site
RunnerConfiguration is a fluent builder. A real run also needs a blueprint reference; this snippet shows the site-target fields in isolation.
<?php require '/php-toolkit/vendor/autoload.php'; use WordPress\Blueprints\Runner; use WordPress\Blueprints\RunnerConfiguration; $config = ( new RunnerConfiguration() ) ->set_execution_mode( Runner::EXECUTION_MODE_APPLY_TO_EXISTING_SITE ) ->set_target_site_root( '/wordpress' ) ->set_target_site_url( 'http://playground.test/' ); echo "mode: " . $config->get_execution_mode() . "\n"; echo "root: " . $config->get_target_site_root() . "\n"; echo "url: " . $config->get_target_site_url() . "\n";
mode: apply-to-existing-site
root: /wordpress
url: http://playground.test/
Generate blueprint JSON from PHP
CI jobs and tests stay clearer when PHP builds the blueprint from data instead of hand-writing JSON. Keep the structure plain: version, top-level collections such as plugins, and any imperative steps under the schema's step lists.
<?php require '/php-toolkit/vendor/autoload.php'; $site_name = 'Demo Site'; $plugins = array( 'gutenberg', 'classic-editor' ); $blueprint = array( 'version' => 2, 'plugins' => array(), 'additionalStepsAfterExecution' => array( array( 'step' => 'setSiteOptions', 'options' => array( 'blogname' => $site_name, 'permalink_structure' => '/%postname%/', 'show_on_front' => 'page', ), ), ), ); foreach ( $plugins as $slug ) { $blueprint['plugins'][] = array( 'source' => $slug, 'active' => true, ); } echo json_encode( $blueprint, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . "\n";
{
"version": 2,
"plugins": [
{
"source": "gutenberg",
"active": true
},
{
"source": "classic-editor",
"active": true
}
],
"additionalStepsAfterExecution": [
{
"step": "setSiteOptions",
"options": {
"blogname": "Demo Site",
"permalink_structure": "/%postname%/",
"show_on_front": "page"
}
}
]
}
Validate before running
The schema validator returns a human-readable ValidationError instead of a generic "does not match schema" failure. Use it before handing user-authored JSON to a runner.
<?php require '/php-toolkit/vendor/autoload.php'; use WordPress\Blueprints\Validator\HumanFriendlySchemaValidator; $schema = array( 'type' => 'object', 'required' => array( 'version', 'steps' ), 'properties' => array( 'version' => array( 'type' => 'integer' ), 'steps' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'required' => array( 'step' ), 'properties' => array( 'step' => array( 'type' => 'string' ), ), ), ), ), ); $blueprint = array( 'version' => 2, 'steps' => array( array( 'source' => 'https://downloads.wordpress.org/plugin/gutenberg.zip' ), ), ); $error = ( new HumanFriendlySchemaValidator( $schema ) )->validate( $blueprint ); if ( null === $error ) { echo "valid\n"; } else { echo $error->get_pretty_path() . ": " . $error->message . "\n"; }
Blueprint root["steps"][0]: Missing required field: step.
The Blueprint JSON shape
A Blueprint v2 document starts with a version field, then uses top-level declarations such as plugins, themes, content, and the schema's step lists. Imperative steps use a "step" discriminator plus step-specific fields.
{
"version": 2,
"plugins": [
{ "source": "gutenberg", "active": true }
],
"additionalStepsAfterExecution": [
{ "step": "setSiteOptions",
"options": {
"blogname": "Demo Site",
"permalink_structure": "/%postname%/"
} },
{ "step": "installPlugin",
"source": "https://downloads.wordpress.org/plugin/classic-editor.zip" },
{ "step": "activatePlugin",
"pluginPath": "classic-editor/classic-editor.php" }
]
}
wp-php-toolkit/blueprints 适用场景与选型建议
wp-php-toolkit/blueprints 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 144 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「php-toolkit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wp-php-toolkit/blueprints 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wp-php-toolkit/blueprints 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wp-php-toolkit/blueprints 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Encoding component for WordPress.
Data Liberation component for WordPress.
XML component for WordPress.
ByteStream component for WordPress.
Filesystem component for WordPress.
HttpClient component for WordPress.
统计信息
- 总下载量: 144
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-09-06