🎉 Get the Insurfin - Insurance Service HTML5 Template for FREE - Offer Ends Soon!

The WP-CLI is a fantastic command-line tool for WordPress developers. You can do almost everything related to WordPress using this command-line tool. On the other hand, Local is another outstanding piece of software for the local WordPress development environment.

I have been working as a web developer for over a decade now.🤩 In the early days of my WordPress themes and plugins development in the local environment, I used XAMPP. I am a big fan of XAMPP. ❤️

However, starting a new WordPress site every time for new projects is extra work and takes a reasonable amount of time. So, I decided to switch from XAMPP to Local.

Fix the WP-CLI scaffold and Local issue

🤔 What is the issue?

Recently, I found some issues while working on a WordPress project and trying to create a custom WordPress plugin. I tried to create the plugin boilerplate using the WP-CLI scaffold command. But, getting an "Error: Error establishing a database connection." error message.

✅ Fix the WP-CLI scaffold and Local issue

👉 Step 01: Open the configuration file

Navigate to the root of the WordPress installation. For local, it is "<YOURSITE>/app/public/". Open the wp-config.php file using any code editor. I preferred to edit the code using Visual Studio Code.

👉 Step 02: Find the database configuration

Find the "DB_HOST" constant from that file. We are going to update the value of that constant in the upcoming steps.

👉 Step 03: Open Database Tab

Now, open the Local application. Navigate to your current running site (check the green circle) and go to "Database" tab.

👉 Step 04: Get the socket data

Copy the socket value and go back to the wp-config.php file.

👉 Step 05: Update configuration file

Add the socket value after the “localhost” text. Add a colon(:) between these two values. Here is the example screenshot.

👉 Step 06: Save the changes

Save the wp-config.php file. Now, again, run the wp scaffold plugin my-wp-plugin command. A new plugin will be created successfully.

Now, you know the solution to fixing the WP-CLI scaffold and local issue.

Total 1 Votes
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

Back To Top
Premium WordPress Themes and Plugins By xenioushk
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.