From 7a09edd3bdefda8a04596cc18c4616a79d1617ad Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Thu, 19 Dec 2024 17:39:34 +0900 Subject: [PATCH 1/6] wp-env: Added phpMyAdmin and multisite support to the documentation --- .../getting-started-with-code-contribution.md | 6 ++++ packages/env/README.md | 29 ++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/docs/contributors/code/getting-started-with-code-contribution.md b/docs/contributors/code/getting-started-with-code-contribution.md index df6b305f35983..2cfe592bc323a 100644 --- a/docs/contributors/code/getting-started-with-code-contribution.md +++ b/docs/contributors/code/getting-started-with-code-contribution.md @@ -128,6 +128,12 @@ Port: {MYSQL_PORT_NUMBER} **Tip**: [Sequel Ace](https://sequel-ace.com/) is a useful GUI tool for accessing a MySQL database. Other tools are available and documented in this [article on accessing the WordPress database](https://developer.wordpress.org/advanced-administration/before-install/creating-database/). +Alternatively, you can use phpMyAdmin to access the mySQL database. To enable access to phpMyAdmin, add the `WP_ENV_PHPMYADMIN_PORT` environment variable to the command: + +```bash +WP_ENV_PHPMYADMIN_PORT=9000 npm run wp-env start +``` + #### Troubleshooting If you run into an issue, check the [troubleshooting section in `wp-env` documentation](/packages/env/README.md#troubleshooting-common-problems). diff --git a/packages/env/README.md b/packages/env/README.md index af037f5ee80ab..dd9df5d3039d6 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -479,17 +479,19 @@ You can customize the WordPress installation, plugins and themes that the develo `.wp-env.json` supports fields for options applicable to both the tests and development instances. -| Field | Type | Default | Description | -|----------------|----------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| -| `"core"` | `string\|null` | `null` | The WordPress installation to use. If `null` is specified, `wp-env` will use the latest production release of WordPress. | -| `"phpVersion"` | `string\|null` | `null` | The PHP version to use. If `null` is specified, `wp-env` will use the default version used with production release of WordPress. | -| `"plugins"` | `string[]` | `[]` | A list of plugins to install and activate in the environment. | -| `"themes"` | `string[]` | `[]` | A list of themes to install in the environment. | -| `"port"` | `integer` | `8888` (`8889` for the tests instance) | The primary port number to use for the installation. You'll access the instance through the port: 'http://localhost:8888'. | -| `"testsPort"` | `integer` | `8889` | The port number for the test site. You'll access the instance through the port: 'http://localhost:8889'. | -| `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. | -| `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. | -| `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. | +| Field | Type | Default | Description | +|--------------------|----------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| +| `"core"` | `string\|null` | `null` | The WordPress installation to use. If `null` is specified, `wp-env` will use the latest production release of WordPress. | +| `"phpVersion"` | `string\|null` | `null` | The PHP version to use. If `null` is specified, `wp-env` will use the default version used with production release of WordPress. | +| `"plugins"` | `string[]` | `[]` | A list of plugins to install and activate in the environment. | +| `"themes"` | `string[]` | `[]` | A list of themes to install in the environment. | +| `"port"` | `integer` | `8888` (`8889` for the tests instance) | The primary port number to use for the installation. You'll access the instance through the port: 'http://localhost:8888'. | +| `"testsPort"` | `integer` | `8889` | The port number for the test site. You'll access the instance through the port: 'http://localhost:8889'. | +| `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. | +| `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. | +| `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. | +| `"phpmyadminPort"` | `integer` | `null` | The phpMyAdmin port number to expose. If a non-null number is defined, phpMyAdmin will be exposed. | +| `"multisite"` | `boolean` | `false` | Whether to set up a multisite installation.. | _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PORT`) take precedent over the .wp-env.json values._ @@ -523,7 +525,8 @@ Additionally, the key `env` is available to override any of the above options on "KEY_1": false }, "port": 3000, - "mysqlPort": 13306 + "mysqlPort": 13306, + "phpmyadminPort": 9001 } } } @@ -688,7 +691,7 @@ You can tell `wp-env` to use a custom port number so that your instance does not } ``` -These can also be set via the environment variables `WP_ENV_PORT`, `WP_ENV_TESTS_PORT`, `WP_ENV_MYSQL_PORT` and `WP_ENV_TESTS_MYSQL_PORT`. +These can also be set via the environment variables `WP_ENV_PORT`, `WP_ENV_TESTS_PORT`, `WP_ENV_MYSQL_PORT`, `WP_ENV_TESTS_MYSQL_PORT`, `WP_ENV_PHPMYADMIN_PORT` and `WP_ENV_TESTS_PHPMYADMIN_PORT`. ### Specific PHP Version From d0bddfb5b8c19e3d1141999a0ddb25654ad23fe1 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:05:05 +0900 Subject: [PATCH 2/6] Fix double periods Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com> --- packages/env/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/env/README.md b/packages/env/README.md index dd9df5d3039d6..fd69269337205 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -491,7 +491,7 @@ You can customize the WordPress installation, plugins and themes that the develo | `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. | | `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. | | `"phpmyadminPort"` | `integer` | `null` | The phpMyAdmin port number to expose. If a non-null number is defined, phpMyAdmin will be exposed. | -| `"multisite"` | `boolean` | `false` | Whether to set up a multisite installation.. | +| `"multisite"` | `boolean` | `false` | Whether to set up a multisite installation. | _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PORT`) take precedent over the .wp-env.json values._ From 159aeeb27690288eb3c03d014b9b032bf440954f Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:05:54 +0900 Subject: [PATCH 3/6] Improve description of phpmyadminPort Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com> --- packages/env/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/env/README.md b/packages/env/README.md index fd69269337205..aedaf186a3ff0 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -490,7 +490,7 @@ You can customize the WordPress installation, plugins and themes that the develo | `"config"` | `Object` | See below. | Mapping of wp-config.php constants to their desired values. | | `"mappings"` | `Object` | `"{}"` | Mapping of WordPress directories to local directories to be mounted in the WordPress instance. | | `"mysqlPort"` | `integer` | `null` (randomly assigned) | The MySQL port number to expose. The setting is only available in the `env.development` and `env.tests` objects. | -| `"phpmyadminPort"` | `integer` | `null` | The phpMyAdmin port number to expose. If a non-null number is defined, phpMyAdmin will be exposed. | +| `"phpmyadminPort"` | `integer` | `null` | The port number for phpMyAdmin. If provided, you'll access phpMyAdmin through: http://localhost: | | `"multisite"` | `boolean` | `false` | Whether to set up a multisite installation. | _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PORT`) take precedent over the .wp-env.json values._ From 78f78277654f6f7759259786a51d2da9900d12a5 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:08:11 +0900 Subject: [PATCH 4/6] Clarify explanation about phpMyAdmin and mysql ports Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com> --- packages/env/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/env/README.md b/packages/env/README.md index aedaf186a3ff0..90c2cd0a6190d 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -691,7 +691,11 @@ You can tell `wp-env` to use a custom port number so that your instance does not } ``` -These can also be set via the environment variables `WP_ENV_PORT`, `WP_ENV_TESTS_PORT`, `WP_ENV_MYSQL_PORT`, `WP_ENV_TESTS_MYSQL_PORT`, `WP_ENV_PHPMYADMIN_PORT` and `WP_ENV_TESTS_PHPMYADMIN_PORT`. +These can also be set via environment variables: +- `WP_ENV_PORT` to override the development environment's web server's port. +- `WP_ENV_TESTS_PORT` to override the testing environment's web server's port. +- phpMyAdmin is not enabled by default, but its port can also be overridden for the development and testing environments via `WP_ENV_PHPMYADMIN_PORT` and `WP_ENV_TESTS_PHPMYADMIN_PORT`, respectively. +- By default, MySQL aren't exposed to the host, which means no chance of port conflicts. But these can also be overridden for the development and testing environments via `WP_ENV_MYSQL_PORT` and `WP_ENV_TESTS_MYSQL_PORT`, respectively. ### Specific PHP Version From c092597696f632c6e11986f3032e0bfa3af4bdde Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 20 Dec 2024 11:14:20 +0900 Subject: [PATCH 5/6] Add a line break --- packages/env/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/env/README.md b/packages/env/README.md index 90c2cd0a6190d..467e8d44e7135 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -692,6 +692,7 @@ You can tell `wp-env` to use a custom port number so that your instance does not ``` These can also be set via environment variables: + - `WP_ENV_PORT` to override the development environment's web server's port. - `WP_ENV_TESTS_PORT` to override the testing environment's web server's port. - phpMyAdmin is not enabled by default, but its port can also be overridden for the development and testing environments via `WP_ENV_PHPMYADMIN_PORT` and `WP_ENV_TESTS_PHPMYADMIN_PORT`, respectively. From 8d50403bc275ec26b9a71bd6c79c37dfa651dc44 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Sat, 4 Jan 2025 13:05:59 +0900 Subject: [PATCH 6/6] Updated the description of phpMyAdmin --- .../code/getting-started-with-code-contribution.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/contributors/code/getting-started-with-code-contribution.md b/docs/contributors/code/getting-started-with-code-contribution.md index 2cfe592bc323a..9afcc3e46ca1b 100644 --- a/docs/contributors/code/getting-started-with-code-contribution.md +++ b/docs/contributors/code/getting-started-with-code-contribution.md @@ -104,7 +104,9 @@ You can access the Dashboard at: `http://localhost:8888/wp-admin/` using **Usern #### Accessing the MySQL Database -To access the MySQL database on the `wp-env` instance you will first need the connection details. To do this: +phpMyAdmin is available by default for the Gutenberg project. You can access the MySQL Database at: `http://localhost:9000/`. + +If you want to access the database through another tool, you will first need the connection details. To do this: 1. In a terminal, navigate to your local Gutenberg repo. 2. Run `npm run wp-env start` - various information about the `wp-env` environment should be logged into the terminal. @@ -128,12 +130,6 @@ Port: {MYSQL_PORT_NUMBER} **Tip**: [Sequel Ace](https://sequel-ace.com/) is a useful GUI tool for accessing a MySQL database. Other tools are available and documented in this [article on accessing the WordPress database](https://developer.wordpress.org/advanced-administration/before-install/creating-database/). -Alternatively, you can use phpMyAdmin to access the mySQL database. To enable access to phpMyAdmin, add the `WP_ENV_PHPMYADMIN_PORT` environment variable to the command: - -```bash -WP_ENV_PHPMYADMIN_PORT=9000 npm run wp-env start -``` - #### Troubleshooting If you run into an issue, check the [troubleshooting section in `wp-env` documentation](/packages/env/README.md#troubleshooting-common-problems).