Table of contents of the article:
For a developer, it is often frustrating to constantly have to manage configurations, install different libraries and deal with commercial licenses. What developers love is writing code, building things, and launching products that help people. In fact, for them the code is poetry.
wp-now is a new configuration-free development environment Automattic recently contributed to for the WordPress Playground. Although it is currently in its alpha stage, wp-now is already the fastest and easiest way to start a local WordPress site.
Automattic wants to help developers focus on what matters most, which is turning caffeine into lines of code and launching products quickly.
wp-now can be installed directly from npm. Works on all platforms (Mac, Linux and Windows). While it doesn't yet support custom domains or SSL, Automattic has plans for it. Contributors to wp-now are also considering auto-detecting when a file is changed and auto-updating the browser, importing a database from another WordPress site, and adding a deploy feature for SSH/SFTP hosting. among other features.
At WordPress.com, contributing to projects like WordPress Playground aligns with the company's mission to provide the best managed hosting platform for WordPress. Over the past year, the developer experience on WordPress.com has been enriched with tools like the WP-CLI, SSH access, and staging sites.
One of the aspects in which wp-now is optimized is the development of Block themes. Let's imagine a developer grappling with a new and challenging project: the creation of a block theme for a prestigious university.
The developer is tired of repeating the same steps over and over: download the latest version of WordPress, set up a new site, and keep track of their login details. He recalls a blog post announcing an innovative tool to explore: "Launch a local environment in seconds with wp-now." So he decides to give it a try since the only requirement is npm and he might finally stop using Docker.
After starting wp-now, a new website with the chosen theme automatically opens in your browser within seconds. He doesn't need to install the theme or enter his credentials, he's already logged in as an administrator.
After some development, he decides to test his theme using the latest WordPress release candidate:
wp-now start --wp=6.3-RC1
His site looks great on his computer, but the client asked to start using PHP 8.2 while WordPress is still at version 6.1. But that's no problem for wp-now:
wp-now start --php=8.2 --wp=6.1.3
At the end of a productive work day, go home with a sense of accomplishment. He realizes that this new tool is excellent for his product development and decides to share it with his colleagues. He can help them with their themes and plugins. As a bonus, it also makes it easy to contribute to WordPress.
Faster than Docker
Under the hood, wp-now uses WordPress Playground, which runs PHP via WebAssembly. Performance matters, so Automattic measured how wp-now compares to the local Docker-based development environment, wp-env.
In general, wp-now is several times faster to get started and just as fast to work:
Task | wp-now | wp-env |
Download dependencies | 10s | 5m |
Start Docker | 0s | 12s |
Start environment | 1.03s | 2.35s |
Load site home page | 0.3s | 0.17s |
Load admin dashboard | 0.34s | 0.17s |
While requests to the pages they tested took about twice as long in the wp-now environment, the absolute differences were in the order of 100-400ms, which shouldn't affect day-to-day development work much.
Powered By WordPress Playground
wp-now is basically a NodeJS application that includes a built-in PHP server, powered by WordPress Playground.
When a user runs wp-now from a directory, wp-now creates an instance of php-wasm, downloads the selected version of WordPress, and mounts the necessary directories into a virtual file system (VFS). Next, they start a NodeJS express server which listens and routes all requests to the php-wasm. As a result, wp-now is able to easily autologin to WordPress, activate plugins and themes, and automatically configure the user's WordPress site.
wp-now relies on the SQLite Database Integration plugin for its database, but can also connect to an existing MySQL database. All project-specific files are kept in the user's home directory, inside the ~/.wp-now folder. Directories are created following this pattern: ~/.wp-now/wp-content/${ProjectFolderName}-${Pathhash}.
In the simplest terms, wp-now is a powerful tool that allows developers to work in a local environment without going through the hassles associated with setting up a WordPress site manually. This NodeJS application handles the technical details and provides a smooth user experience, allowing developers to focus on content creation and site design. With support for both SQLite and MySQL, wp-now offers flexibility in terms of data management, all while keeping your project files tidy and easily accessible.
Open to Contributions
Community contributions are invaluable in improving wp-now and WordPress Playground. Developers and users can help and contribute by sharing their ideas, expressing their opinion on which features are most useful for them, reporting issues, or even creating pull requests for the WordPress Playground Tools GitHub repository. The wp-now team is driven by user feedback – they invite everyone to ask questions and share their ideas.
Here are some future ideas the team is considering:
- Create a template theme/plugin with the wp-now create function.
- Automatic detection when a file is changed and automatic browser update.
- Use wp-now playground to launch a WordPress site without any files.
- Import the database from another WordPress site, whether it's on your computer or hosted externally.
- Add the deploy feature to help developers deploy to any SSH/SFTP hosting.
- Support custom domains.
If users want to build wp-now from its source code, they can follow the steps for contributing. Additionally, you can join the conversation in the #meta-playground channel on Making WordPress Slack.