Skip to content

Commit dbcdf65

Browse files
authored
Reorganize and update documentation (#1354)
## What is this PR doing? 1. Reorganizing the **Contributing** chapter of the docs, and updating the content. See [this issue](adamziel/playground-docs-workflow#31 (comment)) 2. Adding references to [the Developer docs](https://developer.wordpress.org/) in relevant Blueprints steps. See #1291. ~### To-Do:~ - [x] Update [wp-now](https://www.npmjs.com/package/@wp-now/wp-now) README. **Done** in [Update wp-now documentation #251](WordPress/playground-tools#251). ## Testing Instructions 1. Build the site (standard `npm run build` to update the steps in `packages/playground/blueprints/src/lib/steps/`) 2. Run `npm run dev:docs`. 3. Review the changes. @adamziel
1 parent f06f522 commit dbcdf65

36 files changed

+382
-560
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build": "nx run-many --all --target=build",
77
"build:website": "nx build playground-website",
88
"build:docs": "nx build docs-site",
9+
"dev:docs": "nx dev docs-site",
910
"changelog": "bun ./packages/meta/bin/update-changelog.ts; cp CHANGELOG.md packages/docs/site/docs/17-changelog.md",
1011
"deploy:docs": "gh-pages -d dist/docs/build -t true",
1112
"dev": "nx dev playground-website",

packages/docs/site/docs/01-start-here/01-index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ This site (Documentation) is where you will find all the information you need to
2424

2525
- [Start using WordPress Playground](../02-start-using/01-index.md) in 5 minutes (and check out the [demo site](https://playground.wordpress.net/))
2626
- [Build your first app](../03-build-an-app/01-index.md) with WordPress Playground
27-
- Use Playground as a zero-setup [local development environment](../04-nodejs/01-index.md#start-a-zero-setup-dev-environment-via-vscode-extension)
27+
- Use Playground as a zero-setup [local development environment](../05-local-development/02-vscode-extension.md)
2828
- Read about the [limitations](../12-limitations/01-index.md)
29-
- [WordCamp Contributor Day](../14-contributor-day/01-index.md)
29+
- [WordCamp Contributor Day](../13-contributing/09-contributor-day.md)
3030

3131
## Take a deep dive
3232

packages/docs/site/docs/04-nodejs/01-index.md

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
slug: wp-now
3+
---
4+
5+
# wp-now NPM package
6+
7+
[`@wp-now/wp-now`](https://www.npmjs.com/package/@wp-now/wp-now) is a CLI tool to spin up a WordPress site with a single command. Similarly to the [VS Code extension](/05-local-development/02-vscode-extension.md), it uses a portable WebAssembly version of PHP and SQLite. No Docker, MySQL, or Apache are required.
8+
9+
## Launch wp-now in a plugin or theme directory
10+
11+
Navigate to your plugin or theme directory and start `wp-now` with the following commands:
12+
13+
```bash
14+
cd my-plugin-or-theme-directory
15+
npx @wp-now/wp-now start
16+
```
17+
18+
## Launch wp-now in the `wp-content` directory with options
19+
20+
You can also start `wp-now` from any `wp-content` folder. The following example passes parameters for changing the PHP and WordPress versions and loading a blueprint file.
21+
22+
```bash
23+
cd my-wordpress-folder/wp-content
24+
npx @wp-now/wp-now start --wp=6.4 --php=8.0 --blueprint=path/to/blueprint.json
25+
```
26+
27+
:::info **Documentation**
28+
29+
`wp-now` is maintained in a different GitHub repository, [Playground Tools](https://github.com/WordPress/playground-tools/). You can find the latest documentation in the [dedicated README file](https://github.com/WordPress/playground-tools/blob/trunk/packages/wp-now/README.md).
30+
31+
:::
32+
33+
## Install wp-now globally
34+
35+
Alternatively, you can install `@wp-now/wp-now` globally to load it from any directory:
36+
37+
```bash
38+
npm install -g @wp-now/wp-now
39+
cd my-plugin-or-theme-directory
40+
wp-now start
41+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# VS Code extension
2+
3+
Start a zero-setup development environment using the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=WordPressPlayground.wordpress-playground), and develop your plugin or theme locally without installing Apache or MySQL.
4+
5+
:::info **Documentation**
6+
7+
The VS Code extension is maintained in a different GitHub repository, [Playground Tools](https://github.com/WordPress/playground-tools/). You can find the latest documentation in the [dedicated README file](https://github.com/WordPress/playground-tools/blob/trunk/packages/vscode-extension/README.md).
8+
9+
:::
10+
11+
The extension ships with a portable WebAssembly version of PHP and sets up WordPress to use SQLite. Once installed, all you have to do is click the **Start WordPress Server** button in VS Code:
12+
13+
import Image from '@theme/IdealImage';
14+
import vsCodeScreenshot from '@site/static/img/start-wordpress-server.png';
15+
16+
<div style={{maxWidth:350}}><Image img={vsCodeScreenshot} /></div>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: php-wasm/node
3+
---
4+
5+
# Using WordPress Playground in Node.js
6+
7+
As a WebAssembly project, you can also use WordPress Playground in Node.js.
8+
9+
If you need low-level control over the underlying WebAssembly PHP build, take a look at the [`@php-wasm/node` package](https://npmjs.org/@php-wasm/node) which ships the PHP WebAssembly runtime. This package is at the core of all WordPress Playground tools for Node.js.
10+
11+
:::info **API reference**
12+
13+
Consult the [complete list](/api/node) of Classes, Functions, Interfaces, and Type Aliases.
14+
15+
:::
16+
17+
import PHPWASMNode from '@php-wasm/node/\README.md';
18+
19+
<PHPWASMNode />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"label": "Local Development"
3+
}

packages/docs/site/docs/06-playground-apis/02-api-concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Concepts
66

77
WordPress Playground in the browser is all about links and iframes. Regardless of which API you choose, you will use it in one of the following ways:
88

9-
### Link to the Playground site
9+
## Link to the Playground site
1010

1111
You can customize WordPress Playground by modifying the https://playground.wordpress.net/ link. You can, for example, create a post, request a specific plugin, or run any PHP code.
1212

packages/docs/site/docs/11-architecture/01-index.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Architecture Overview
1+
# Architecture overview
22

33
WordPress Playground consists of the following high-level components:
44

@@ -9,3 +9,22 @@ WordPress Playground consists of the following high-level components:
99
- [Public API](../06-playground-apis/01-index.md)
1010

1111
Visit each section to learn more about the specific parts of the architecture.
12+
13+
## Tooling
14+
15+
### NX: building packages and projects
16+
17+
WordPress Playground uses [NX](https://nx.dev/), a build system designed for monorepos.
18+
19+
The dependencies between Playground packages and projects [are too complex](https://github.com/WordPress/wordpress-playground/pull/151) for a bundler like Webpack, and NX handles this complexity much better:
20+
![Dependency graph](@site/static/img/dependencies.png)
21+
22+
To learn more, head over to the [NX developer docs](https://nx.dev/getting-started/intro).
23+
24+
### Lerna: publishing packages and projects
25+
26+
WordPress Playground includes several NPM packages, a VS Code extension, WordPress plugins, a web app, and other GitHub releases, all managed across two monorepos: the main [wordpress-playground](https://github.com/WordPress/wordpress-playground) and [Playground Tools](https://github.com/WordPress/playground-tools/).
27+
28+
We use [Lerna](https://lerna.js.org) to build, manage, and publish all JavaScript/TypeScript packages. Lerna handles everything simultaneously: it increments the version number, sets a new tag, and publishes the modified packages to `npm`.
29+
30+
The published packages share the same version number, so when updating a single package, Lerna bumps the version number of all dependent packages.
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# Iframe-based rendering
22

3-
All the PHPRequestHandler responses must be rendered in an iframe to avoid reloading the page. Remember, the entire setup only lives as long as the main `index.html`. We want to avoid reloading the main app at all cost.
3+
To avoid page reloads, all the `PHPRequestHandler` responses must be rendered in an iframe. Remember, the entire setup only lives as long as the main `index.html`. We want to avoid reloading the main app at all costs.
44

55
In our app example above, `index.php` renders the following HTML:
66

77
```html
88
<a href="page.php">Go to page.php</a>
99
```
1010

11-
Imagine our `index.html` rendered it in a `<div>` instead of an `<iframe>`. As soon as you clicked on that link, the browser would try to navigate from `index.html` to `page.php`. However, `index.html` runs the entire PHP app including the Worker Thread, the PHPRequestHandler, and the traffic control connecting them to the Service Worker. Navigating away from it would destroy the app.
11+
Imagine our `index.html` rendered it in a `<div>` instead of an `<iframe>`. As soon as you click on that link, the browser will try to navigate from `index.html` to `page.php`. However, `index.html` runs the entire PHP app, including the Worker Thread, the PHPRequestHandler, and the traffic control connecting them to the Service Worker. Navigating away from it would destroy the app.
1212

1313
Now, consider an iframe with the same link in it:
1414

1515
```html
1616
<iframe srcdoc='<a href="page.php">Go to page.php</a>'></iframe>
1717
```
1818

19-
This time, clicking the link the browser to load `page.php` **inside the iframe**. The top-level index.html where the PHP application runs remains unaffected. This is why iframes are a crucial part of the `@php-wasm/web` setup.
19+
This time, click the link in the browser to load `page.php` **inside the iframe**. The top-level `index.html`, where the PHP application runs, remains unaffected. That's why iframes are crucial for the `@php-wasm/web` setup.
20+
21+
:::info Crash reports
22+
Playground doesn't collect crash reports automatically. Instead, it prompts users to submit a crash report when an instance fails to run in the browser.
23+
24+
The report includes a log, description, and a URL, and users can modify it before submitting it.
25+
26+
The [Logger API](https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/website/public/logger.php) handles it from there. This simple REST API validates the data and sends it to the **Making WordPress** [#playground-logs Slack channel](https://wordpress.slack.com/archives/C06Q5DCKZ3L).
27+
:::
2028

2129
## Iframes caveats
2230

23-
- `target="_top"` isn't handled yet. This means that clicking on `<a target="_top">Click here</a>` will reload the main browser tab.
24-
- JavaScript popup windows originating in the iframe may not work correctly yet.
31+
- `target="_top"` isn't handled yet, so clicking links with `target="_top"` will reload the page you’re working on.
32+
- JavaScript popups originating in the `iframe` may not always display.

packages/docs/site/docs/11-architecture/15-wordpress.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
---
2-
title: WordPress support
3-
---
4-
51
# WordPress support
62

73
WordPress, as a PHP application, can run on PHP WebAssembly. However, there are a few caveats.
84

95
## SQLite
106

11-
First, WordPress requires MySQL. However, there isn't a WebAssembly version of MySQL you could run in the browser. WordPress Playground therefore ships PHP with the [native SQLite driver](https://www.php.net/manual/en/ref.pdo-sqlite.php) and leans on SQLite.
7+
First, WordPress requires MySQL. However, there isn't a WebAssembly version of MySQL you could run in the browser. WordPress Playground, therefore, ships PHP with the [native SQLite driver](https://www.php.net/manual/en/ref.pdo-sqlite.php) and leans on SQLite.
128

139
But how can WordPress run on a different database?
1410

1511
Behind the scenes, the official [SQLite Database Integration](https://github.com/WordPress/sqlite-database-integration) plugin intercepts all MySQL queries and rewrites them in SQLite dialect. The x.0 release ships [a new WordPress Playground-informed translation layer](https://github.com/WordPress/sqlite-database-integration/pull/9) that allows WordPress on SQLite to pass 99% of the WordPress unit test suite.
1612

1713
## WordPress in the browser
1814

19-
WordPress Playground ships a [bundled WordPress](./06-wasm-php-data-dependencies.md) that you can use in the browser. It's optimized for size and the installation wizard is already completed for you.
15+
WordPress Playground ships a [bundled WordPress](./06-wasm-php-data-dependencies.md) that you can use in the browser. It's optimized for size, and the installation wizard is run for you.
2016

2117
## WordPress in Node.js
2218

packages/docs/site/docs/11-architecture/18-host-your-own-playground.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ git clone -b trunk --single-branch --depth 1 [email protected]:WordPress/wordpress-
5858
```
5959

6060
Enter the `wordpress-playground` directory.
61+
6162
```sh
6263
cd wordpress-playground
6364
```
@@ -98,11 +99,9 @@ For these to work, you need a server environment with Apache and PHP installed.
9899

99100
As an alternative to Apache, here is an example of using NGINX to serve the Playground.
100101

101-
:::info Refer to source files
102-
103-
This example may go out of date. It is recommended to refer to the source files.
102+
:::info Refer to the source file
104103

105-
- [packages/playground/wordpress/public/.htaccess](https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/wordpress/public/.htaccess)
104+
The example may be outdated. Please check [the source file](https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/remote/.htaccess) for the latest version.
106105

107106
:::
108107

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
---
2-
title: Limitations
32
slug: /limitations
43
---
54

65
# Limitations
76

8-
WordPress Playground has a few limitations that you should be aware of.
7+
WordPress Playground is under active development and has some limitations you should keep in mind when running it and developing with it.
98

10-
## If you are a user
9+
You can track the status of these issues on the [Playground Project board](https://github.com/orgs/WordPress/projects/180).
1110

12-
import Limitations from '@site/docs/\_fragments/\_limitations_ui.md';
11+
## In the browser
1312

14-
<Limitations />
13+
### Access the Plugins, Themes, Blocks, or Patterns directories
1514

16-
## If you are a developer
15+
Playground [disables network connections](../09-blueprints-api/03-data-format.md#features) by default, blocking access to wp.org assets (themes, plugins, blocks, or patterns) in `wp-admin`. You can still upload zipped plugin and theme files from your device or enable the option via the [Query API](../08-query-api/01-index.md#available-options) or [Blueprints API](../09-blueprints-api/09-troubleshoot-and-debug-blueprints.md#review-common-gotchas).
1716

18-
### Iframe quirks
17+
### Temporary by design
1918

20-
WordPress is rendered in an iframe, which makes it hard to correctly handle `target="_top"` in links. This means that clicking on `<a target="_top">Click here</a>` may reload the main browser tab.
19+
As Playground [streams rather than serves](../01-start-here/02-overview.md#streamed-not-served) WordPress, all database changes and uploads will be gone when you refresh the page. To avoid losing your work, either [export your work](../02-start-using/01-index.md#save-your-site) before or enable storage in the browser/device via the [Query API](../08-query-api/01-index.md#available-options) or the UI.
2120

22-
Also, JavaScript popup windows originating in the iframe may not be displayed in certain cases.
21+
## When developing with Playground
2322

24-
### Pthreads Support
23+
### Iframe quirks
2524

26-
The WebAssembly version of PHP is built without pthreads support, which means you cannot use `pcntl_` functions like `pcntl_fork()` or `pcntl_exec()`. Most of the time, you don't need them, but there are a few WP-CLI commands and a few corner-cases in PHPUnit tests that use them.
25+
Playground renders WordPress in an `iframe` so clicking links with `target="_top"` will reload the page you’re working on.
26+
Also, JavaScript popups originating in the `iframe` may not always display.
2727

28-
You can track the progress of adding pthreads support at https://github.com/WordPress/wordpress-playground/issues/347.
28+
### Run WordPress PHP functions
2929

30-
### XDebug Support
30+
Playground supports running PHP code in Blueprints using the [`runPHP` step](../09-blueprints-api/05-steps.md#RunPHPStep). To run WordPress-specific PHP functions, you’d need to first require [wp-load.php](https://github.com/WordPress/WordPress/blob/master/wp-load.php):
3131

32-
XDebug is not supported in the WebAssembly version of PHP. You can track the progress of adding XDebug support at https://github.com/WordPress/wordpress-playground/issues/314.
32+
```json
33+
{
34+
"step": "runPHP",
35+
"code": "<?php require_once('wordpress/wp-load.php'); OTHER_CODE ?>"
36+
}
37+
```
3338

34-
### Fibers
39+
### Using WP-CLI
3540

36-
Fibers are a PHP 8.1+ feature that is currently unsupported in Playground. See https://github.com/WordPress/wordpress-playground/blob/9065025043209ce06c9540886567ca5bc0ccfb11/packages/php-wasm/compile/Dockerfile#L484-L493 for more information.
41+
You can execute `wp-cli` commands via the Blueprints [`wp-cli`](../09-blueprints-api/05-steps.md#WPCLIStep) step. However, since Playground runs in the browser, it doesn't support the [full array](https://developer.wordpress.org/cli/commands/) of available commands. While there is no definite list of supported commands, experimenting in [the online demo](https://playground.wordpress.net/demos/wp-cli.html) will help you assess what's possible.
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
---
2-
title: Start Contributing
3-
---
1+
# Start contributing
42

5-
# Start Contributing
6-
7-
WordPress Playground is an open-source project and welcomes all contributors from code to design, and from documentation to triage. Don't worry, you don't need to know WebAssembly to contribute!
3+
WordPress Playground is an open-source project that welcomes all contributors—from code to design, documentation to triage.
84

95
## How can I contribute?
106

117
- Code? See the [developer section](./02-code.md).
128
- Documentation? See the [documentation section](./20-documentation.md).
13-
- Reporting bugs? Open an [issue](https://github.com/WordPress/wordpress-playground/issues/new) in the repository.
14-
- Triage – see the [triage section](./05-triage.md).
15-
- Ideas, designs or anything else? Open a [GitHub discussion](https://github.com/WordPress/wordpress-playground/discussions) and let's talk!
9+
- Reporting bugs? Open a [new issue](https://github.com/WordPress/wordpress-playground/issues/new) in the main GitHub repository, or in [Playground Tools](https://github.com/WordPress/playground-tools/issues/new).
10+
- Ideas, designs, or anything else? Open a [GitHub discussion](https://github.com/WordPress/wordpress-playground/discussions), and let's talk!
1611

1712
## Guidelines
1813

19-
- As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://make.wordpress.org/handbook/community-code-of-conduct/).
20-
- Contributors should review the [coding standards](./03-coding-standards.md).
21-
- You maintain copyright over any contribution you make. By submitting a pull request you agree to release that code under [WordPress Playground License](https://github.com/WordPress/wordpress-playground/blob/HEAD/LICENSE).
14+
- As with all WordPress projects, we want to ensure a welcoming and respectful environment for everyone. Please read our community's [Code of Conduct](https://make.wordpress.org/handbook/community-code-of-conduct/) to learn more.
15+
- Code contributors should review the [coding principles](./03-coding-standards.md).
16+
- You maintain copyright over any contribution you make. By submitting a Pull Request, you agree to release that code under [WordPress Playground License](https://github.com/WordPress/wordpress-playground?tab=GPL-2.0-1-ov-file#readme).
17+
18+
# Triaging issues
19+
20+
Want to help sort through open issues and resolve potential bugs? Here's how:
21+
22+
1. Review the [list of open issues](https://github.com/WordPress/wordpress-playground/issues?q=is%3Aopen+is%3Aissue) and find the ones that you can help with. Same goes for the [Plaground Tools repository](https://github.com/WordPress/playground-tools/issues?q=is%3Aopen+is%3Aissue).
23+
2. Read through the description and comments.
24+
3. If it's a bug you can reproduce, add a descriptive comment or a potential fix.
25+
4. Otherwise, add a comment with any additional information that may be helpful.

0 commit comments

Comments
 (0)