wp-now: Launch a Local Environment in Seconds

As a developer, it’s frustrating to constantly deal with configurations, install various libraries, and commercial licenses. We enjoy writing code, building things, and shipping products that help people. Code is poetry.

wp-now is a new, zero-config development environment we recently contributed to the WordPress Playground. Currently in its alpha stage, wp-now is already the fastest and easiest way to spin up a local WordPress site. We want to help developers focus on what matters most, which is transforming caffeine into lines of code and shipping products quickly.

At WordPress.com, contributing to projects like WordPress Playground complements our mission to provide the best managed WordPress hosting platform. Over the last year, we’ve been enriching the WordPress.com developer experience with tools like WP-CLI, SSH access, and staging sites.

Optimized for Block Theme Development

Imagine yourself on a challenging new project: building a block theme for a prestigious university.

You’re also tired of repeating the same steps: downloading the latest WordPress version, setting up a new site, and keeping track of your login details. You remember a blog post announcing an innovative tool worth exploring: “Launch a Local Environment in Seconds with wp-now”

So you ask yourself, “Why not give it a try? The only requirement is npm, and I’ll be able to stop using Docker”.

You give it a whirl…

Within a matter of seconds, a new website using your chosen theme automatically opens in your browser. You didn’t need to install the theme or enter your credentials. You are already logged in as an admin.

After a bit of development, you decide to test your theme using the latest WordPress release candidate:

wp-now start --wp=6.3-RC1

Your site looks great on your machine, but the client has called that they want to start using PHP 8.2 and WordPress is still at version 6.1. Not a problem for wp-now:

wp-now start --php=8.2 --wp=6.1.3

With a sense of accomplishment, you head home from a productive day at work. You realize that this new tool is excellent for developing your products and decide to share it with your colleagues. It can help them with their themes and plugins as well. As an added bonus, it even makes it easy to contribute back to WordPress.

Faster Than Docker

Under the hood, wp-now uses WordPress Playground, which executes PHP using WebAssembly. Performance is important, so we measured how wp-now compares to the Docker-based wp-env local development environment.

Overall, wp-now is many times faster to get started with, and just as fast to work with:

Taskwp-nowwp-env
Download dependencies10s5m
Start Docker0s12s
Start environment1.03s2.35s
Load site home page0.3s0.17s
Load admin dashboard0.34s0.17s

Even though requests to the pages we tested take about two times longer in the wp-now environment, the absolute differences were in the range of 100-400ms, which shouldn’t affect daily development work much.

Screenshot showing the requests in the Network tab in DevTools.

Powered by WordPress Playground

wp-now is essentially a NodeJS app with a built-in PHP server powered by WordPress Playground.

When you use wp-now from a directory, we create a php-wasm instance, download the selected WordPress version and mount the necessary directories in a virtual file system (VFS). Then, we initiate a NodeJS express server that listens and proxies all requests to the php-wasm. As a result, wp-now can easily log you into WordPress automatically, activate plugins and themes, and automatically configure your WordPress site.

wp-now relies on SQLite Database Integration plugin for its database, and can also connect to an existing MySQL database. All of the project-specific files are stored in your home directory under the folder ~/.wp-now. The directories are created in this pattern: ~/.wp-now/wp-content/${projectFolderName}-${pathHash}

Ready for Contributions

Contributions from the community are invaluable in improving wp-now and WordPress Playground. You can help and contribute by sharing your ideas, expressing your opinions about what features are most useful for you, reporting issues or even creating pull requests to the WordPress Playground Tools GitHub repository. We are driven by your feedback — please ask questions and share your ideas.

Here are some future ideas that we are considering:

  • Create a boilerplate theme/plugin with wp-now create.
  • Auto detect when a file is modified and automatically refresh the browser.
  • wp-now playground to start a WordPress site without any files.
  • Import database from another WordPress site, on your machine, or hosted externally.
  • Add deploy feature to help developers deploy to any SSH/SFTP hosting.
  • Support custom domains.

If you want to build wp-now from its source code, you can follow the contribution steps. You can also join us for conversation in the #meta-playground channel on Making WordPress Slack​.

Thanks to Daniel Bachhuber, Javier Arce and Wojtek Naruniec for their contributions to this post.


Comments

2 responses to “wp-now: Launch a Local Environment in Seconds”

  1. This is fantastic! Thank you for sharing!

    How difficult is it to set up XDebug in this environment?

    1. Awesome! Glad to hear you like it 🙂

      XDebug isn’t currently supported but is something we want to look into in the future.