Title: wp-env: Simple Local Environments for WordPress.
Author: Noah Allen
Published: March 3, 2020

---

 [  ](https://profiles.wordpress.org/noahtallen/) [Noah Allen](https://profiles.wordpress.org/noahtallen/)
10:47 pm _on_ March 3, 2020     
Tags: wp-env   

# wp-env: Simple Local Environments for WordPress.

Local WordPress environments are now as simple as running a single command. `[wp-env](https://developer.wordpress.org/block-editor/packages/packages-env/)`
is a zero config tool for painless local WordPress environments. It provides decisions
over options so that users can quickly spin up WordPress without wasting time. Indeed,
the goal is to make these environment easily accessible to all — whether you’re 
a developer, designer, manager, or anyone else. It really is this straightforward:

 1. From the directory of your WordPress source code, pluginPlugin A plugin is a piece
    of software containing a group of functions that can be added to a WordPress website.
    They can extend functionality or add new features to your WordPress websites. WordPress
    plugins are written in the PHP programming language and integrate seamlessly with
    WordPress. These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
    or can be cost-based plugin from a third-party., or theme, run `wp-env start`.
 2. Access the instance on localhost:8888. The local code is already mapped and ready
    for development!

In this basic example, there is no configuration. `wp-env` creates a Docker instance
behind the scenes with the latest WordPress image and then maps the local theme 
or plugin to the environment as a Docker volume. This way, any changes you make 
to the code locally are reflected immediately in the WordPress instance.

`wp-env` requires both [Docker](https://www.docker.com/) and [Node](https://nodejs.org/).
Once these prerequisites are met, you can run `npm install -g @wordpress/env` to
install `wp-env` locally. Feel free to test it out from the root of the [Gutenberg repository](https://github.com/wordpress/gutenberg)!

For more advanced use cases, the experience is just as simple after one includes
a short configuration file (called `.wp-env.json`) in the source code. Running `
wp-env start` in the same directory as a `.wp-env.json` file will automatically 
start and configure everything for you according to the specifications in the file.
This makes it easy for new folks to start contributing or testing in advanced environments
without having to configure anything themselves.

The `.wp-env.json` file allows you to create fairly advanced local development setups.
[Here is the documentation for the config file](https://developer.wordpress.org/block-editor/packages/packages-env/#wp-env-json),
and below is an advanced use case:

    ```language-json
    {
      "core": "https://wordpress.org/wordpress-5.4-beta2.zip",
      "plugins": [
        "../../my-fancy-plugin/",
        "https://downloads.wordpress.org/plugin/classic-editor.1.5.zip",
        ".",
        "WordPress/gutenberg#master"
      ],
      "port": 1000,
      "testsPort": 1001,
      "config": {
        "WP_DEBUG_DISPLAY": true
      }
    }
    ```

The `core` field allows us to specify a source for the coreCore Core is the set 
of software required to run WordPress. The Core Development Team builds WordPress.
WordPress code. Additionally, the `plugins` and `themes` fields allow us to specify
sources for plugins and themes. These sources can be in several formats: relative
or absolute local paths, a GitHubGitHub GitHub is a website that offers online implementation
of git repositories that can easily be shared, copied and modified by other developers.
Public repositories are free to host, private repositories require a paid subscription.
GitHub introduced the concept of the ‘pull request’ where code changes done in branches
by contributors can be reviewed and discussed before being merged by the repository
owner. [https://github.com/](https://github.com/) repository, or a URLURL A specific
web address of a website or web page on the Internet, such as a website’s URL www.
wordpress.org to a .zip file.

In the above example, we see the following:

 * The `core` field is mapped to a betaBeta A pre-release of software that is given
   out to a large group of users to trial under real conditions. Beta versions have
   gone through alpha testing in-house and are generally fairly close in look, feel
   and function to the final product; however, design changes often occur as part
   of the process. version of WordPress in the .zip format.
 * The `plugins` field contains several plugins. The first is a local path to a 
   plugin, the next is a zip file, the third is the plugin in the same directory
   as the `.wp-env.json` file, and last is a reference to the `master` branchbranch
   A directory in Subversion. WordPress uses branches to store the latest development
   code for each major release (3.9, 4.0, etc.). Branches are then updated with 
   code for any minor releases of that branch. Sometimes, a major version of WordPress
   and its minor versions are collectively referred to as a "branch", such as "the
   4.0 branch". of the GutenbergGutenberg The Gutenberg project is the new Editor
   Interface for WordPress. The editor improves the process and experience of creating
   new content, making writing rich content much simpler. It uses ‘blocks’ to add
   richness rather than shortcodes, custom HTML etc. [https://wordpress.org/gutenberg/](https://wordpress.org/gutenberg/)
   GitHub repository.
 * The `port` field overrides the port on which the instance is mounted. In this
   case, we access WordPress at http://localhost:1000.
 * The `config` field sets `wp-config.php` constants. Here, the `WP_DEBUG_DISPLAY`
   constant is set to `true` in the created WordPress instance.

You might need to create this file if your plugin or theme has a lot of dependencies
or options required for development. Instead of offloading this configuration work
to the consumer, `.wp-env.json` makes the development and testing of advanced setups
easily accessible to anyone with `wp-env` installed.

Finally, props to [@noisysocks](https://profiles.wordpress.org/noisysocks/) and 
[@epiqueras](https://profiles.wordpress.org/epiqueras/) for making this tool possible.
If you’d like to learn more about `wp-env`, see [the documentation page](https://developer.wordpress.org/block-editor/packages/packages-env/),
read [the source code](https://github.com/WordPress/gutenberg/tree/master/packages/env),
or [follow development progress](https://github.com/WordPress/gutenberg/labels/%5BPackage%5D%20Env).
As always, feel free to open issues or pull requests on GitHub if you find bugs 
or have suggestions concerning the tool.

[#wp-env](https://make.wordpress.org/core/tag/wp-env/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/?share=linkedin)

 1.  ![](https://secure.gravatar.com/avatar/947cd60adce308d5ba8772143832343bbec847703364425b696af78313f3f909?
     s=32&d=mm&r=g)
 2.   [leeshadle](https://profiles.wordpress.org/leeshadle/)  12:03 am _on_ March 4,
     2020
 3.  This is awesome, great work! I love the ease of adding different ports, plugins
     and themes.
 4.  Is this a significantly different implementation than the wp-scripts env? I use
     the wp-scripts env for blockBlock Block is the abstract term used to describe 
     units of markup that, composed together, form the content or layout of a webpage
     using the WordPress editor. The idea combines concepts of what in the past may
     have achieved with shortcodes, custom HTML, and embed discovery into a single 
     consistent API and user experience. development and I’m wondering what the major
     differences are?
 5.   * ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
        s=32&d=mm&r=g)
      *  [noahtallen](https://profiles.wordpress.org/noahtallen/)  12:24 am _on_ March
        4, 2020
      * Great question! `wp-env` is ultimately intended to replace `wp-scripts env`,
        though we are still working on steps for deprecation. I think we need to integrate
        the phpunit and phpcsPHP Code Sniffer [PHP Code Sniffer,](https://github.com/squizlabs/PHP_CodeSniffer)
        a popular tool for analyzing code quality. The [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards/)
        rely on PHPCS. steps with wp-env, but other than that, wp-env should support
        the things that wp-scripts env does and more. I guess there are some steps 
        it does not directly support in the same way (install, reinstall, and connect),
        but those are supported via the .wp-env.jsonJSON JSON, or JavaScript Object
        Notation, is a minimal, readable format for structuring data. It is used primarily
        to transmit data between a server and web application, as an alternative to
        XML. file now.
      * The implementation is pretty different. wp-scripts env relies on downloading
        and building the development version of WordPress in a subdirectory of the 
        pluginPlugin A plugin is a piece of software containing a group of functions
        that can be added to a WordPress website. They can extend functionality or 
        add new features to your WordPress websites. WordPress plugins are written 
        in the PHP programming language and integrate seamlessly with WordPress. These
        can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
        or can be cost-based plugin from a third-party. you’re working within. For 
        wp-env, a hidden directory `~/.wp-env` is created, and every time you run the
        tool, it finds or creates an entry there for the current directory you’re working
        in. This way, all of the dependencies are out of the way of your own development
        environment.
      * Additionally, by default, wp-env uses the production WordPress image for Docker
        which means installation is a lot faster. Also, you don’t have to work with
        the less stable version of WordPress if you don’t need to.
      * The other difference is that wp-env entirely abstracts the Docker configuration
        to make things more simple. The thought is that if you need the super advanced
        things that Docker can allow you to do, you might as well use it directly. 
        For wp-env, we’re trying to expose an APIAPI An API or Application Programming
        Interface is a software intermediary that allows programs to interact with 
        each other and share data in limited, clearly defined ways. that makes things
        easier for WordPress developers, so the Docker configuration itself is also
        put in the hidden `~/.wp-env `directory.
      * Let me know if you have other questions about it. 🙂
         - ![](https://secure.gravatar.com/avatar/947cd60adce308d5ba8772143832343bbec847703364425b696af78313f3f909?
           s=32&d=mm&r=g)
         -  [leeshadle](https://profiles.wordpress.org/leeshadle/)  1:39 am _on_ March
           4, 2020
         - Thank you! I tried it out and it’s like magic, I love having the entire 
           ~/.wp-env directory hidden away and being able to easily define themes and
           plugins to have at startup is clutch!
         - Is there a way to run WP-CLIWP-CLI WP-CLI is the Command Line Interface 
           for WordPress, used to do administrative and development tasks in a programmatic
           way. The project page is [http://wp-cli.org/](http://wp-cli.org/) [https://make.wordpress.org/cli/](https://make.wordpress.org/cli/)
           commands against the WordPress install?
            * ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
              s=32&d=mm&r=g)
            *  [noahtallen](https://profiles.wordpress.org/noahtallen/)  2:32 am _on_
              March 4, 2020
            * Glad you like it! Yep, you can run CLICLI Command Line Interface. Terminal(
              Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress. commands
              through the `wp-env run` command. So this command is like `docker-compose
              run`. Since wp-env includes an image for WP-CLIWP-CLI WP-CLI is the Command
              Line Interface for WordPress, used to do administrative and development
              tasks in a programmatic way. The project page is [http://wp-cli.org/](http://wp-cli.org/)
              [https://make.wordpress.org/cli/](https://make.wordpress.org/cli/), you
              can do something like this:
            *     ```notranslate
                  wp-env run cli wp plugin activate
                  ```
              
               - `run` says “run the command in the docker instance”
               - `cli` says “use the CLI docker service on the current instance”
               - `wp` references WP-CLI.
               - And then the rest is the CLI command 🙂
 6.  ![](https://secure.gravatar.com/avatar/806814895466fbffe3a788a45451b3afa695570f8c2a6f6913db6aa5e2cb3178?
     s=32&d=mm&r=g)
 7.   [Mikel King](https://profiles.wordpress.org/vizkr/)  12:25 am _on_ March 4, 2020
 8.  This is fantastic…
 9.  Curious are dropins and mu-plugins supported?
 10.  * ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
        s=32&d=mm&r=g)
      *  [noahtallen](https://profiles.wordpress.org/noahtallen/)  12:29 am _on_ March
        4, 2020
      * At the moment, there isn’t a way to interact with those other than by running
        commands on the underlying Docker container. It definitely sounds like a good
        idea for future enhancements, though!
         - ![](https://secure.gravatar.com/avatar/806814895466fbffe3a788a45451b3afa695570f8c2a6f6913db6aa5e2cb3178?
           s=32&d=mm&r=g)
         -  [Mikel King](https://profiles.wordpress.org/vizkr/)  12:51 pm _on_ March
           11, 2020
         - I added a feature requestfeature request A feature request should generally
           begin the process in the ideas forum, on a mailing list, as a plugin, or
           brought to the attention of the core team, such as through scope meetings
           held for each major release. Unsolicited tickets of this variety are typically,
           therefore, discouraged. => [https://github.com/WordPress/gutenberg/issues/20790](https://github.com/WordPress/gutenberg/issues/20790)
 11. ![](https://secure.gravatar.com/avatar/2915e1013f968e0a0272b4d95ca3296049b5e4e53ae8a3cad515780e59b69adc?
     s=32&d=mm&r=g)
 12.  [jakeparis](https://profiles.wordpress.org/jakeparis/)  3:31 pm _on_ March 4,
     2020
 13. It looks like there’s no way to login to the adminadmin (and super admin) with
     this?
 14.  * ![](https://secure.gravatar.com/avatar/947cd60adce308d5ba8772143832343bbec847703364425b696af78313f3f909?
        s=32&d=mm&r=g)
      *  [leeshadle](https://profiles.wordpress.org/leeshadle/)  3:33 pm _on_ March
        4, 2020
      * You can login with:
         user: **adminadmin (and super admin)** pass: **password**
         - ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
           s=32&d=mm&r=g)
         -  [noahtallen](https://profiles.wordpress.org/noahtallen/)  8:13 pm _on_ 
           March 4, 2020
         - Right on!
 15. ![](https://secure.gravatar.com/avatar/944ddfc8d4b2f5bad1918020a033eeb4c59f850565d2b7f286efa210fde70db2?
     s=32&d=mm&r=g)
 16.  [David Smith](https://profiles.wordpress.org/get_dave/)  4:08 pm _on_ March 4,
     2020
 17. Thank you for all your work on this.
 18. ![](https://secure.gravatar.com/avatar/75f0f2c68e98799c913158b3253a84bffe60cb83335db3095b802c89a8aee056?
     s=32&d=mm&r=g)
 19.  [rheinardkorf](https://profiles.wordpress.org/rheinardkorf/)  11:01 pm _on_ March
     4, 2020
 20. This is an amazing start. Congrats on the tool!
 21. I’ve raised a new feature requestfeature request A feature request should generally
     begin the process in the ideas forum, on a mailing list, as a plugin, or brought
     to the attention of the core team, such as through scope meetings held for each
     major release. Unsolicited tickets of this variety are typically, therefore, discouraged.
     issue on the repo to support use of alternate Docker images: [https://github.com/WordPress/gutenberg/issues/20636](https://github.com/WordPress/gutenberg/issues/20636)
 22. Thanks for the effort thus far 💪
 23. ![](https://secure.gravatar.com/avatar/2ea47d663b87477b6d767ced154b0ff775ecd100be9b2ce5171cbdeb83dcad31?
     s=32&d=mm&r=g)
 24.  [Sean Leavey](https://profiles.wordpress.org/seanleavey/)  11:48 am _on_ March
     11, 2020
 25. Looks awesome! I’d like to try this but before I can I’d ideally like support 
     for phpunit and phpcsPHP Code Sniffer [PHP Code Sniffer,](https://github.com/squizlabs/PHP_CodeSniffer)
     a popular tool for analyzing code quality. The [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards/)
     rely on PHPCS. – is there a timeline for these being added? Also, how is the database
     implemented – do we have for example a way to manage the database with tools like
     phpMyAdmin (I guess not?)?
 26.  * ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
        s=32&d=mm&r=g)
      *  [noahtallen](https://profiles.wordpress.org/noahtallen/)  12:49 am _on_ March
        12, 2020
      * You can seem more discussion around phpunit here: [https://github.com/WordPress/gutenberg/pull/20090](https://github.com/WordPress/gutenberg/pull/20090).
        There’s not any timeline at the moment, unfortunately.
      * > Also, how is the database implemented
      * It’s another service on the resulting Docker image:
      * [https://github.com/WordPress/gutenberg/blob/e8c7e9768c5f4eed7d5dcc92c5592424f0a52f83/packages/env/lib/build-docker-compose-config.js#L67-L73](https://github.com/WordPress/gutenberg/blob/e8c7e9768c5f4eed7d5dcc92c5592424f0a52f83/packages/env/lib/build-docker-compose-config.js#L67-L73)
      * I think the only way to access the DB at the moment is through wp-cliWP-CLI
        WP-CLI is the Command Line Interface for WordPress, used to do administrative
        and development tasks in a programmatic way. The project page is [http://wp-cli.org/](http://wp-cli.org/)
        [https://make.wordpress.org/cli/](https://make.wordpress.org/cli/) commands,
        like `wp-env run cli wp db check`. I think it’d be a great idea to add straightforward
        support for phpMyAdmin or something like that. (Feel free to open an issue 
        in the GutenbergGutenberg The Gutenberg project is the new Editor Interface
        for WordPress. The editor improves the process and experience of creating new
        content, making writing rich content much simpler. It uses ‘blocks’ to add 
        richness rather than shortcodes, custom HTML etc.
         [https://wordpress.org/gutenberg/](https://wordpress.org/gutenberg/)
        repo!)
 27. ![](https://secure.gravatar.com/avatar/51f55d5974ff861cb88d8b52880f8c15b7f37150ccbad2f47352878a2c9dc2d1?
     s=32&d=mm&r=g)
 28.  [John Blackbourn](https://profiles.wordpress.org/johnbillion/)  4:14 pm _on_ 
     March 28, 2020
 29. [@noahtallen](https://profiles.wordpress.org/noahtallen/) How does wp-env differ
     from the local environment that’s bundled with the develop version of WordPress
     coreCore Core is the set of software required to run WordPress. The Core Development
     Team builds WordPress.? Is it the same or different?
 30.  * ![](https://secure.gravatar.com/avatar/7321fecc42a79ae35714736aa231b3c8a801887656a6104876384f7a4e21e114?
        s=32&d=mm&r=g)
      *  [noahtallen](https://profiles.wordpress.org/noahtallen/)  1:10 am _on_ March
        29, 2020
      * Great question! They are two different tools with no dependency on each other.
        The top level differences:
         - The environment bundled with wp coreCore Core is the set of software required
           to run WordPress. The Core Development Team builds WordPress. dev is only
           for setting up development in that specific repo. Its specific purpose is
           to run a single command to launch a Docker environment to develop WordPress
           core. It’s for a specific use case.
         - wp-env is for developing any type of WordPress entity (pluginPlugin A plugin
           is a piece of software containing a group of functions that can be added
           to a WordPress website. They can extend functionality or add new features
           to your WordPress websites. WordPress plugins are written in the PHP programming
           language and integrate seamlessly with WordPress. These can be free in the
           WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
           or can be cost-based plugin from a third-party., theme, and/or WordPress
           core) in any place. So I can use wp-env for standalone plugin development,
           standalone theme development, WordPress core development, or all at the 
           same time. It’s for the general use case.
      * Previously, `@wordpress/scripts env` was written for the general case, and 
        it _did_ use the wp core dev environment under the hood. When you used wp-scripts
        env, it would download the WordPress core development repo and then run commands
        within the repo to accomplish things.
      * This approach only got us so far and wasn’t always easy to use. And many use
        cases weren’t possible. wp-env replaces wp-scripts env for that general use
        case tool, and it implements everything internally so that it doesn’t need 
        to download a version of the core develop environment to run its commands.
      * You could actually run wp-env start in the root of the WordPress develop repository,
        and it should work fine as a local environment for that as well. I suspect 
        that we may want to start consolidating if it makes sense. Then again wp-env
        is not intended to replace advanced workflows. Rather, it should be simple 
        to use for the general use case.
 31. ![](https://secure.gravatar.com/avatar/0608b540c7da83b396fd9a453ad1ac0298152522bc3a06888d41649e4024a089?
     s=32&d=mm&r=g)
 32.  [Ahmad Awais](https://profiles.wordpress.org/mrahmadawais/)  6:59 pm _on_ April
     3, 2020
 33. This amazing. An idea like this has been stuck in my head for a while. I was going
     to start building it when Matt Cromwell mentioned this tool. Thank you for building
     it. I’ll help contribute.
 34. ![](https://secure.gravatar.com/avatar/5478c55437f47714a4dae1016cf521e803dfc4633ce5781b2f24d749d1623f69?
     s=32&d=mm&r=g)
 35.  [Rua Haszard](https://profiles.wordpress.org/haszari/)  4:21 am _on_ April 17,
     2020
 36. 👌Love this! Lowers the barriers to hacking on blocks, plugins and themes 🙂

Comments are closed.

# Post navigation

[← Fullscreen mode enabled by default in the editor](https://make.wordpress.org/core/2020/03/03/fullscreen-mode-enabled-by-default-in-the-editor/)

[CSS Chat Agenda: 5th March 2020 →](https://make.wordpress.org/core/2020/03/04/css-chat-agenda-5th-march-2020/)