If you want to host and run a WordPress Playgroundyou can install it via Node.js. First install node.js – if you don’t have it yet, follow the guide on the node.js webpage.
Node.js works on Linux, Mac and Windows.
Then install the package wp-now by npm, like this_
sudo npm install -g @wp-now/wp-now
cd my-plugin-or-theme-directory
npx @wp-now/wp-now start
- First line: on Linux and Mac use sudo, but probably not on windows.
- Second line: you change to the directory with the theme or plugin to be tested.
- Third line: now this will install WordPress in a hidden directort, and open a browser after a few seconds.
Then you’re ready to develop or test.
Reset
When you restart the site will appear as when you left it. However, sometimes you may need a new version. You can reset your site like this, and then you’ll get a new WP for your experiments:
npx @wp-now/wp-now start --reset
Start in a Theme Directory
A fast way to test a theme is to start wp-now up in the theme directory or in a plugin directory. Wp-now will then open WordPress in that theme. This is supereasy:
cd /localhost/wordpress/wp-content/themes/your-theme/
npx @wp-now/wp-now start
Blueprint
A blueprint is a JSON file, that will define settings like the version of PHP or WordPress. You can install plugins and themes via blueprints too. You can load the blueprint like this:
npx @wp-now/wp-now start --blueprint=path/to/blueprint.json
The content of blueprint.json could be something along these lines:
{
"landingPage": "/wp-admin/",
"preferredVersions": {
"php": "7.4",
"wp": "5.9"
},
"phpExtensionBundles": [
"kitchen-sink"
],
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "instant-images"
},
"options": {
"activate": true
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "w3-total-cache"
},
"options": {
"activate": true
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "wordpress-seo"
},
"options": {
"activate": false
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "ewww-image-optimizer"
},
"options": {
"activate": true
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "blocks-animation"
},
"options": {
"activate": true
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org\/plugins",
"slug": "font-awesome"
},
"options": {
"activate": true
}
}
]
}
“Man” wp-now start — help
Here are the options from the man page:
Options:
–version Show version number [boolean]
–path Path to the PHP or WordPress project. Defaults to the current working directory. [string]
–php PHP version to use. [string]
–wp WordPress version to use: e.g. ‘–wp=6.2’ [string]
–port Server port [number]
–blueprint Path to a blueprint file to be executed [string]
–reset Create a new project environment, destroying the old project environment. [boolean]
–skip-browser Do not launch the default browser
[boolean] [default: false]
–inspect Use Node debugging client. [number]
–inspect-brk Use Node debugging client. Break immediately on script execution start. [number]
–trace-exit Prints a stack trace whenever an environment is exited proactively, i.e. invoking process.exit(). [number]
–trace-uncaught Print stack traces for uncaught exceptions; usually, the stack trace associated with the creation of an Error is
printed, whereas this makes Node.js also print the stack trace associated with throwing the value (which does not need to be an Error instance). [number]
–trace-warnings Print stack traces for process warnings (including deprecations). [number]
-h, –help Show help [boolean]
For more information, see: