It has been more than a year since I switched to Local by Flywheel for the local development of WordPress websites. I must admit that it is one of the best tools available for local development ? Local by Flywheel uses Docker to create WordPress sites in separate containers.

One thing that stuck out after switching was the use of WP-CLI ? WP-CLI is an essential tool for WordPress developers because it helps to speed up our workflow. However, to access the CLI for a website on Local by Flywheel, you have to go through a two-step process.

✅ Right-click on the name of the website in Local and select Open Site SSH. As a result, a new terminal window will appear which will automatically log you in via SSH protocol, and then WP-CLI becomes available for you.

?‍? So, to streamline my workflow, I started searching for a solution which does not require logging into the container to access the CLI. And I made a CLI of my own, local-wpcli

? Introducing local-wpcli

local-wpcli creates configuration files which enable WP-CLI — installed on your computer — to connect with locally hosted websites of Local by Flywheel within your terminal. Use the following command in your terminal to install it globally.

npm install --global local-wpcli

⚙️ How it Works

Once the installation is complete, follow these steps to connect WP-CLI with your WordPress site.

  • 1️⃣ Open your terminal and go to the root folder of the website.
cd ~/local-sites/local-wp/
  • 2️⃣ Now input the following command and press enter.
local-wpcli
  • 3️⃣ The CLI will ask the following details:
    → Remote Host (IP Address) — default is 192.168.95.100
    → Remote Port

You can find the details mentioned above in DATABASE tab of the website in Local by Flywheel’s desktop app.

The CLI creates two configuration files in the root folder namely,

  • 1️⃣ wp-cli.local.yml
  • 2️⃣ wp-cli.local.php

That’s it ? Once the files are created, WP-CLI will be ready to use to your heart’s content ?

Leave a Reply