Skip to content

[Documentation] Adding troubleshooting sections for WP-CLI database connections #2333

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

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

fellyph
Copy link
Collaborator

@fellyph fellyph commented Jul 7, 2025

Motivation for the change, related issues

Issue #2332 identified a scenario where additional steps are required to mount WP-CLI with a mounted playground. This pull request adds a guide for the user to run WP-CLI command successfully with WordPress Playground.

Implementation details

  • Adds a new troubleshooting section to /blueprints/troubleshoot-and-debug detailing how to resolve "Error establishing a database connection".
  • Includes a corresponding Blueprint example in /blueprints/examples for quick reference.

Testing Instructions (or ideally a Blueprint)

  • Download the branch adding-blueprints-tips.
  • Install the node dependencies.
  • Run the documentation npm run dev:docs

@fellyph fellyph requested a review from bgrgicak July 7, 2025 09:37
@adamziel
Copy link
Collaborator

adamziel commented Jul 7, 2025

Lovely, thank you @fellyph! I wonder if we could recognize that type of error and link to the doc page from the error message 🤔

@@ -85,6 +85,33 @@ blueprint={{
]
}} />

## Running WP-CLI on Mounted Sites
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (asking because I'm not sure): Is this only relevant to mounted sites? What I mean is, can you run WP-CLI commands on a non-mounted site?

I don't think you can, so it might be useful to reframe this around how to run WP CLI commands on a playground instance, ie, you need to mount the /wordpress/ folder, and also configure the SQLite integration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the section. You are right, the point is how to connect the playground with the WP-CLI.

@@ -11,6 +11,54 @@ When you build Blueprints, you might run into issues. Here are tips and tools to

- Require `wp-load`: to run a WordPress PHP function using the `runPHP` step, you’d need to require [wp-load.php](https://github.com/WordPress/WordPress/blob/master/wp-load.php). So, the value of the `code` key should start with `"<?php require_once('wordpress/wp-load.php'); REST_OF_YOUR_CODE"`.
- Enable `networking`: to access wp.org assets (themes, plugins, blocks, or patterns), or load a stylesheet using [add_editor_style()](https://developer.wordpress.org/reference/functions/add_editor_style/) (say, when [creating a custom block style](https://developer.wordpress.org/news/2023/02/creating-custom-block-styles-in-wordpress-themes)), you’d need to enable the `networking` option: `"features": {"networking": true}`.
-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, the way this is worded makes it sound like you can run WP-CLI from non-mounted sites, which I don't think you can. (Happy to be proven wrong). My experience was that I needed to mount /wordpress/ locally to get WP-CLI working, so the documentation should rather be reframed around "How to get WP-CLI working with Playground"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanbossenger does it read better now? I saw @fellyph added a relevant commit after this interaction

@@ -85,6 +85,37 @@ blueprint={{
]
}} />

## How to work with WP-CLI on Playground

To run WP-CLI commands on a Playground instance, you need to set up two things: mount the `/wordpress/` directory to your local filesystem and ensure the SQLite database integration is correctly configured. These steps allow WP-CLI to recognize the site as a valid WordPress installation and connect to its database.
Copy link
Collaborator

@adamziel adamziel Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note you can run WP-CLI commands via a special Blueprint step. This section is specific to running WP-CLI commands from your terminal when the WordPress site was created via Playground CLI – let's explain that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants