-
Notifications
You must be signed in to change notification settings - Fork 274
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
Playground CLI #1289
Merged
Merged
Playground CLI #1289
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…teStreaming method once the spy has been called
…equent loading attempts
…HP instances equal standing (there's a single authoritative MEMFS that's proxied to all other PHPs)
The request handler needs to decide whether to serve a static asset or run the PHP interpreter. For static assets it should just reuse the primary PHP even if there's 50 concurrent requests to serve. However, for dynamic PHP requests, it needs to grab an available interpreter. Therefore, it cannot just accept PHP as an argument as serving requests requires access to ProcessManager.
I'm not 100% confident in the Node PHP build changes but I can't get lerna publish to work fromy branch with a dist tag so I'll go ahead, merge, publish from a CI job, and revert if anything goes wrong. |
adamziel
added a commit
that referenced
this pull request
Apr 30, 2024
#1289 shipped a PHP.wasm building logic that used an import statement instead of composing a path of __dirname. It did that to support Bun bundling, as Bun needs those static imports to include the .wasm files in the single executable. Unfortunately, that change broke npm bundling and publishing, resulting in a broken package that doesn't ship the correct paths and builds a broken index.cjs file.
adamziel
added a commit
that referenced
this pull request
Apr 30, 2024
) #1289 shipped a PHP.wasm building logic that used an import statement instead of composing a path of __dirname. It did that to support Bun bundling, as Bun needs those static imports to include the .wasm files in the single executable. Unfortunately, that change broke npm bundling and publishing, resulting in a broken package that doesn't ship the correct paths and builds a broken index.cjs file.
1 task
adamziel
added a commit
to adamziel/playground-docs-workflow
that referenced
this pull request
May 1, 2024
…eneration (#59) This PR ships a Blueprint that generates the static site using the Simply Static plugin and the `run-blueprint` feature WordPress/wordpress-playground#1289. Usage: ```shell bash build-static-site.sh # the site is now rendered in the output directory ```
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WordPress Playground CLI
A CLI tool for running WordPress playground locally instead of in the browser.
Usage when testing this PR
The end goal is to create a portable cross-OS server binary with Bun, see #1056 for more context.
Usage after merging this PR
Flexible and unoppinionated
Playground CLI is simple, configurable, and unoppinionated. You can set it up
to your unique WordPress setup. For example, this command would run the documentation
workflow at https://github.com/adamziel/playground-docs-workflow:
It is long, sure, but it is also very flexible. If you need a shorter version, you can alias
it or write a bash script. In the future, Blueprints might support relative path mappings,
at which point that command would get much shorter.
Usage
Playground CLI supports three commands:
server
- start a fresh WordPress playground server.build-snapshot
– run a Blueprint and output a .zip file with the resulting WordPress instance.run-blueprint
– just run the Blueprint and exitHere's the CLI usage:
Server
Playground is a WordPress server:
Builder
Playground can build a
Blueprint.json
file into awordpress.zip
:All the mounts you specify will still apply.
Philosophy
The data flow is as follows:
On each run, a fresh WordPress release is unzipped in the virtual filesystem. It is sourced
from a zip file cached at
~/.wordpress-playground/
. If you mess up your site, just restart theserver and you'll get a fresh one, again unzipped. The CLI tool never modifies the zip file
so you can always be sure you're starting from a clean slate.
Future work
In the guture, Playground CLI may support:
Conceptually, this isn't too different from Docker containers. There are images (zip files),
containers (running instances), and commands (Blueprints). Playground could support the same
concepts such as:
php
command)build
command)Interoperability
This CLI package is not just a useful tool. It drives interoperability between the in-browser
Playground, CLI packages, and the PHP Blueprints library. Once complete, it will reuse the
same internals as the website at https://playground.wordpress.org whether we're talking about
running PHP code, executing Blueprints, building snapshots, serving requests, or maintaining
multiple PHP instances
Known issues
Running a blueprint
and100%
.Possible improvements
How do I run the binary? I'm getting an error!
@stoph Wrote this excellent guide:
Once downloaded find the file in your terminal. If you initially try to run it, you’ll get an error
You’ll need to grant execute permissions to allow it to run
You’ll then get a pop-up form MacOS warning about untrusted code.
Find the file in your Finder. Right click and select “Open” This should not give you the option to Open from the dialog.
Once that’s done, you can close the terminal it launched and should be able to run it without issue from the command line going forward.
cc @dmsnell