-
Notifications
You must be signed in to change notification settings - Fork 10
Snapshots Support #9
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
Comments
Here's an article I once wrote about Snapshots: Playground as the WordPress export formatI propose Playground-powered WordPress Snapshots as the canonical site export format for WordPress core. A Playground export already enables what no other export format may ever be able to do:
What inside the Playground export today?An exported Playground site is a zip with I think it would be more useful as a complete WordPress site with all WordPress core files in it. This way, that snapshot would just work without any additional downloads. It could be bundled with Playground as a single executable and would continue to work 10 years from now. What else is possible with more work?Playground itself, complete with the portable PHP binary, could be bundled with the exported Snapshot. This would make the export self-contained and usable locally, on any device, and independently from playground.wordpress.net. WordPress could export itself into the Snapshot format. This would instantly unlock spinning a "temporary test copy" of your site. WordPress could import from Snapshots to enable easy site transfers and easy "committing" of the changes from the test site. The above features would also unlock "site templates" that you could turn into real WordPress sites with a few clicks. What's wrong with WXR, XML, CSV, JSON, Markdown, etc?Nothing. These are great formats for exporting content. However, they aren't well suited for exporting entire sites. Exporting an entire site as XML or JSON is lossy and requires more work than just exporting an entire site. What about advanced setups that require, e.g., Redis?They won't be supported initially. Eventually, WebAssembly may replace Docker containers enough that we'll be able to bundle more parts of the stack. What about really large sites, like 1GB or 300GB?They won't be supported initially, but with additional work in Playground and WordPress core they absolutely can be supported:
As a side note, a direct transfer may be a better fit for those huge sites than an export file. More about that on Trac. |
Here's another one: What Blueprints and WordPress Snapshots are good and bad atAre you considering Blueprints for your project? Have you considered WordPress Snapshots? This post will give you a good idea of the strengths and weaknesses of both of these formats. Blueprints are recipes for building WordPress Snapshots. A WordPress Snapshot = Blueprint + Build step. In Docker analogy, these are Dockerfiles. WordPress Snapshots are collections of, optionally zipped, files. They contain all the PHP source code, database data, static assets, and metadata necessary to start a WordPress website -- for example, in WordPress Playground or wp-now. In Docker analogy, these are Docker Images. Snapshots are data, Blueprints are computations. Let's also define a WordPress Website. It is a running, living organism where the source code, the PHP runtime, the database connection, and the hosting setup all work together so that you can use a web browser to read (or publish) that cool news article. In Docker terms, sites are Containers. Things both Blueprints and WordPress Snapshots are good at
WordPress Snapshots are useful for users, designers, testers, and developersWordPress Snapshots strengths
WordPress Snapshots weaknesses
Blueprints are for advanced developers with specific needsYou would typically write a Blueprint if a) you're a developer and b) you need a WordPress build script. One-off Websites are so easy to create with wp-admin that most people wouldn't even think about Blueprints, but simply start clicking. Blueprints strengths
Blueprints weaknesses
|
@bph – would either of the writeups above make sense as a documentation page or a make.wp.org post? |
@adamziel I'll review this when I get back next week. |
## Blueprints v2 runner > [!WARNING] > This is an early alpha version. Proceed with caution! This PR ships a reference implementation of a subset of the [Blueprints version 2](https://github.com/Automattic/php-toolkit/blob/19aef3f7273da85ef0927937827c642bf9aa9fb9/components/Blueprints/Versions/Version2/json-schema/wsp/wsp-1-blueprint-v2-schema/proposal.md) spec. It consists of: * A CLI runner tool (bundled as .phar) for easy consumption * A PHP library that can be integrated in other PHP software These tools are compatible with PHP 7.2+ on Mac, Linux, Windows and require no PHP extensions. Libraries for processing ZIP, HTTP, XML, HTML, and Git are included. This huge PR also: * Downgrades the codebase to PHP 7.2 * Gets the unit tests to run * Resolves a number of bugs in most components (HttpClient, Zip, Filesystem, ByteStream, and more) * Introduces an all-php TCP server for testing Splitting it into atomic changes and documenting them could easily take a week. Therefore I apologize, but I am not going to do that. Let's treat it as the new initial commit and apply atomic changes from this point forward. ## Remaining work First and foremost: **stabilize this runner with a large and meaningful suite of tests**. Other than that: ### In this PR - [x] Remove the buggy, experimental HTTP cache support from this PR ### Independently of this PR * Consolidate and prioritize the `@TODO` comments in a way that can be discussed and tracked * A large set of unit tests for the HTTP client covering all sorts of use-cases * (nice to have) An actual, reliable HTTP cache implementation for faster execution * A unit test suite running the 100 most popular Blueprints ### Out of scope until the baseline functionality works * Integrate Data Liberation data importers. The runner uses the [HumanMade/WordPress-importer](https://github.com/humanmade/WordPress-Importer/) for now. ## Using it Download blueprints.phar from [the latest alpha release](https://github.com/Automattic/php-toolkit/releases/tag/v0.0.3-alpha) and follow the instructions there. For running from source, use this command: ``` > php ./components/Blueprints/bin/blueprint.php WordPress Blueprint Runner Usage: php blueprint.php exec <blueprint> --site-url=<url> --site-path=<path> [options] Positional arguments: blueprint Path / URL / DataReference to the blueprint (required) Options: -u, --site-url <value> Public site URL (https://example.com) --site-path <value> Target directory with WordPress install context) (required) -x, --execution-context <value> Source directory with Blueprint context files -m, --mode <value> Execution mode (create|apply) (default 'create') -d, --db-engine <value> Database engine (mysql|sqlite) (default 'mysql') --db-host <value> MySQL host (default 'localhost') --db-user <value> MySQL user (default 'root') --db-pass <value> MySQL password (default '') --db-name <value> MySQL database (default 'wordpress') -p, --db-path <value> SQLite file path (default 'wp.db') --dry-run Don’t change anything, just validate (default false) -h, --help Show full help (default false) -V, --version Show version (default false) Examples: php blueprint.php exec my-blueprint.json --site-url https://mysite.test --site-path /var/www/mysite.com php blueprint.php exec my-blueprint.json --execution-context /var/www --site-url https://mysite.test --mode apply --site-path ./site ``` Here's an example of using it to create a new site (with a complex v1 Blueprint to showcase compatibility): ``` > php ./components/Blueprints/bin/blueprint.php exec https://github.com/wordpress/blueprints/blob/trunk/blueprints/stylish-press/blueprint.json --site-path=./newsite/ --site-url=http://127.0.0.1:4356 --db-engine=sqlite --mode create Creating a new site Site URL: http://127.0.0.1:4356 Site path: /www/php-toolkit/untracked/newsite Blueprint: /www/php-toolkit/untracked/blueprint.json [100%] Complete ✔ Blueprint successfully executed. ``` https://github.com/user-attachments/assets/5565037c-28f0-40cc-9e6d-19e1b86d66dd The command above created a new WordPress site in a `newsite` directory. Here's what it did under the hood: * Validated Blueprint v1 and transpiled it to v2 schema * Reported live progress * Downloaded files in parallel * Imported content and media files * Ran code in subprocesses With another Blueprint, you could also create new post types, source data directly from a git repo, and more. ## Scripts ### Bundle `blueprints.phar` To build a single `blueprints.phar` executable, install [box](https://github.com/box-project/box) and run: ```bash composer build-blueprints-phar # Under the hood it runs: # box compile -c phar-box.json # and recreates dist/blueprints.phar ``` ### Regenerate JSON Schema based on TypeScript types This PR ships a copy of the [Blueprints v2 proposal](Automattic/wordpress-playground-private#109) including the TypeScript types. To regenerate the JSON schema used to validate input Blueprints, run: ```bash # Install dependencies npm install composer regenerate-json-schema # Under the hood, it runs: # node components/Blueprints/json-schema/regenerate-schema.ts # and recreates components/Blueprints/json-schema/blueprint-v2-schema.json ``` --------- Co-authored-by: Brandon Payton <[email protected]>
Let's define the relationship between Snapshots and Blueprints.
wp-content/plugins
, that starts resembling a Snapshot.{"theme": "twentytwentythree"}
instead of shipping the actual files. That's a smaller archive and an up-to-date theme import.Blueprints and Snapshots are a spectrum, not distinct ideas
The smallest WordPress setup description is an empty Blueprint
{}
.The most extensive description is a full Snapshot + Playground binary bundled as a double click executable – click, and that exact site runs on your computer.
There's so much in between, though:
wp-config.php
wp-content
with more plugins and themesThe text was updated successfully, but these errors were encountered: