Repository navigation
Docs: Move DevEnv to own section for docs #23593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ae9a23e
f3130ea
5c65fdc
fed1376
55e274a
81b59e4
3e51693
ff3f6c6
4014c29
346fda0
2ad518d
500479a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,16 @@ | ||
| # Development Environment | ||
|
|
||
| We will need a place to work and tools for creating a block, this is often referred to as the development environment. The three main pieces needed for our development environment are: | ||
| The development environment setup guide is for setting up your local development environment for JavaScript development; creating plugins and tools for extending WordPress and the block editor. | ||
|
|
||
| A development environment is a catch-all term for the setup on your computer to work. The three main pieces needed for our development environment are: | ||
|
|
||
| 1. Node/NPM Development Tools | ||
| 2. WordPress Development Site | ||
| 3. Code Editor | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The short guide. In terminal - Mac, Windows or Linux. Download and install Docker. Startup Docker (?) ... In terminal. Do something (?) You should now have a local development environment in place. If something does not work then check the uninstall guide to remove and start over. - @mkaz and @noahtallen it would be good to have a section for uninstalling all that we have installed. To start over if needed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The do something step is from the Create a Block tutorial, on generating the plugin directory see wp-plugin.md. The create block script creates a plugin directory, you run the wp-env start from within that directory.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can uninstall wp-env like so:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The do something step is confusing as we are having nice and logical steps on what to do in terminal to setup a local WordPress development. I expect the do something step will then create the local WordPress development site which we can then easily access. I am saying the same thing just below. We should not refer to another tutorial as that information can come later.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Noah! Btw how do we test to see that all of it is actually uninstalled?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is actually uninstalled, then Verifying that the environment was properly uninstalled is kind of complicated because you have to understand how Docker works and how wp-env works under the hood, since several different things are cleaned up when you run
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking as long as one gets the error messages one is supposed to get then that would be the confirmatation that it is uninstalled. |
||
| ## Development Tools | ||
|
|
||
| The tools needed for development are **Node** and **NPM**. **Nodejs** is a runtime environment that allows running JavaScript outside of the browser. NPM is the Node Package Manager, it is used for installing dependencies and running scripts. The script `npx` is installed with `npm` and is used to run packages not yet installed, we will use this to bootstrap a block. | ||
| The tools needed for development are **Node** and **NPM**. **Nodejs** is a runtime environment that allows running JavaScript outside of the browser. NPM is the Node Package Manager, it is used for installing dependencies and running scripts. The script `npx` is also installed with Nodejs—this script is used to run packages not yet installed—we will use `npx` to bootstrap a block. | ||
|
|
||
| The tools are used to convert the JavaScript we are going to write into a format that browsers can run. This is called transpiling or the build step. | ||
|
|
||
|
|
@@ -18,15 +20,36 @@ For Windows, or alternative installs, you can [download a Nodejs installer](http | |
|
|
||
| Here are the quick instructions to install using nvm, see the [full installation instructions](https://github.com/nvm-sh/nvm#installing-and-updating) for additional details. | ||
|
|
||
|
mkaz marked this conversation as resolved.
Resolved
|
||
| A tip for macOS Catalina, the default profile file may not be created, you can create the required file typing `touch ~/.zshrc` on the command-line. It is fine to run if the file already exists. Note, `~/` is a shortcut to your home directory. | ||
|
|
||
| Run the following on the command-line to install nvm: | ||
|
|
||
| ```sh | ||
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash | ||
| ``` | ||
|
|
||
| After installing nvm, you need to use it to install node, to install the latest version of node, run: | ||
| Note: On macOS, the required developer tools are not installed by default, if not already installed you may be prompted to download the install. | ||
|
|
||
| <img src="https://developer.wordpress.org/files/2020/07/git-install-prompt.png" alt="Mac git command requies command line developer tools" width="400" height="195"/> | ||
|
|
||
| After installing nvm, you need to use it to install node, to install the LTS version of node, run: | ||
|
|
||
| ```sh | ||
| nvm install --lts | ||
| ``` | ||
|
|
||
| If there is an error running the above command, for example a common error that occurs is: | ||
|
|
||
| ```sh | ||
| $ nvm install --lts | ||
| zsh: command not found: nvm | ||
| ``` | ||
|
|
||
| First, try quitting and restarting your terminal to pick up the installed config. | ||
|
|
||
| If restarting did not resolve the problem, you might need to create the default profile file. | ||
|
|
||
| On macOS Catalina, the default shell is zsh, to create the profile file type `touch ~/.zshrc` on the command-line. It is fine to run if the file already exists. Note, `~/` is a shortcut to your home directory. For Ubuntu, including WSL, the default profile is bash, use `touch ~/.bashrc` to create. | ||
|
|
||
| After creating the profile file, re-run the install command: | ||
|
|
||
| ```sh | ||
| nvm install --lts | ||
|
|
@@ -52,20 +75,32 @@ The WordPress [wp-env package](https://www.npmjs.com/package/@wordpress/env) let | |
|
|
||
| The `wp-env` package requires Docker to be installed. There are instructions available for installing Docker on [Windows 10 Pro](https://docs.docker.com/docker-for-windows/install/), [all other versions of Windows](https://docs.docker.com/toolbox/toolbox_install_windows/), [macOS](https://docs.docker.com/docker-for-mac/install/), and [Linux](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script). | ||
|
|
||
| After confirming that the prerequisites are installed, install `wp-env` globally from the command-line using: | ||
| After you have installed Docker, go ahead and install `wp-env` globally from the command-line using: | ||
|
|
||
| ```sh | ||
| npm -g install @wordpress/env | ||
| ``` | ||
|
|
||
| This will be used in the next [Plugin step](wp-plugin.ms). To confirm it is installed and available, run: | ||
| To confirm it is installed and available, run: | ||
|
|
||
| ```sh | ||
| wp-env --version | ||
| > 1.4.0 | ||
| > 1.6.0 | ||
| ``` | ||
|
|
||
| The `wp-env` script is used to create a Docker WordPress environment, to use start from your plugin directory—if you are following the create block tutorial, this would be in the generated directory. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is confusing going from working in terminal to suddenly mentioning the plugin directory. "...if you are following the create block tutorial, this would be in the generated directory." (I added a similar comment in the below solved comment thread, but as it got hidden I am adding it again here.)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure setting up a dev environment with no context makes much sense. There is a reason you are setting up an environment, the most likely is for developing a plugin or theme. If you are following the create a block tutorial it provides the context in that tutorial here. Otherwise, you might of come to this page wanting to setup an environment to create a plugin, so you would have that in mind already.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We has this introduction: This is how I understand it: "If you are following the create a block tutorial it provides the context in that tutorial here." |
||
| ```sh | ||
| wp-env start | ||
|
mkaz marked this conversation as resolved.
Resolved
|
||
| ``` | ||
|
|
||
|
mkaz marked this conversation as resolved.
Resolved
|
||
| ### Alternatives | ||
| You can access your environment in your browser at: [http://localhost:8888/](http://localhost:8888/), the default username is `admin` and default password is `password`. For more information controlling the Docker environment see the [@wordpress/env package readme](/packages/env/README.md). | ||
|
|
||
| If you are developing a single plugin, you should run `wp-env start` from that plugin working directory—it will mount and activate the plugin automatically. Note: This also works for themes, run from the directory you are developing the theme. | ||
|
|
||
| If you want a single environment for all your plugins/themes, you need to create a `.wp-env.json` in a working directory and add the plugins/themes to it. You then run `wp-env start` from the same directory as that config file. See the [@wordpress/env package for additional details](/packages/env/README.md#wp-envjson). | ||
|
|
||
|
mkaz marked this conversation as resolved.
Resolved
|
||
| ### Alternative to Docker | ||
|
|
||
| A block is just a plugin, so any WordPress environment can be used for development. A couple of alternatives that might be easier, since they do not require Docker install and setup. | ||
|
|
||
|
|
@@ -84,5 +119,3 @@ The important part is having a WordPress site installed, and know where and how | |
| Alternative editors include [Sublime Text](https://www.sublimetext.com/) that is also available across platforms, though is a commercial product; or other free alternatives include [Vim](https://www.vim.org/), [Atom](https://atom.io/), and [Notepad++](https://notepad-plus-plus.org/) all support standard JavaScript style development. | ||
|
|
||
| You can use any editor you're comfortable with, it is more a personal preference. The development setup for WordPress block editor is a common JavaScript environment and most editors have plugins and suppport. The key is having a way to open, edit, and save text files. | ||
|
|
||
| Next Section: [WordPress Plugin](wp-plugin.md) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| # Tutorials | ||
|
|
||
| * See the [Getting Started with JavaScript Tutorial](/docs/designers-developers/developers/tutorials/javascript/readme.md) to learn about how to use JavaScript within WordPress. | ||
| - First things first, see [setting up your development environment](/docs/designers-developers/developers/tutorials/devenv/readme.md) for the tools and setup you need to extend the block editor. | ||
|
|
||
| * The [Blocks Tutorial](/docs/designers-developers/developers/tutorials/block-tutorial/readme.md) is the best place to start to learn more about block creation. | ||
| - See the [Getting Started with JavaScript Tutorial](/docs/designers-developers/developers/tutorials/javascript/readme.md) to learn about how to use JavaScript within WordPress. | ||
|
|
||
| * See the [Meta Boxes Tutorial](/docs/designers-developers/developers/tutorials/metabox/readme.md) for new ways of extending the editor storing and using post meta data. | ||
| - The [Blocks Tutorial](/docs/designers-developers/developers/tutorials/block-tutorial/readme.md) is the best place to start to learn more about block creation. | ||
|
|
||
| * Check out the [Notices Tutorial](/docs/designers-developers/developers/tutorials/notices/README.md) to learn how to display informational UI at the top of the editor. | ||
| - See the [Meta Boxes Tutorial](/docs/designers-developers/developers/tutorials/metabox/readme.md) for new ways of extending the editor storing and using post meta data. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR, but can we move Meta Boxes Tutorial further? :) |
||
|
|
||
| * The [Sidebar Tutorial](/docs/designers-developers/developers/tutorials/sidebar-tutorial/plugin-sidebar-0.md) will walk you through the steps of creating a sidebar to update data from the `post_meta` table. | ||
| - Check out the [Notices Tutorial](/docs/designers-developers/developers/tutorials/notices/README.md) to learn how to display informational UI at the top of the editor. | ||
|
|
||
| * Learn how to add customized buttons to the toolbar with the [Format API tutorial](/docs/designers-developers/developers/tutorials/format-api/). | ||
| - The [Sidebar Tutorial](/docs/designers-developers/developers/tutorials/sidebar-tutorial/plugin-sidebar-0.md) will walk you through the steps of creating a sidebar to update data from the `post_meta` table. | ||
|
|
||
| * Build your own [custom block editor instance](/docs/designers-developers/developers/platform/custom-block-editor/) - this will walk you through building a standalone instance of the block editor within WP Admin. | ||
| - Learn how to add customized buttons to the toolbar with the [Format API tutorial](/docs/designers-developers/developers/tutorials/format-api/). | ||
|
|
||
| - Build your own [custom block editor instance](/docs/designers-developers/developers/platform/custom-block-editor/) - this will walk you through building a standalone instance of the block editor within WP Admin. | ||
Uh oh!
There was an error while loading. Please reload this page.