Download the VirtualBox package as you would install it and run the VirtualBox_Uninstall.tool script; move Local by Flywheel to the trash. This second step is the one that needs to be done instead of just moving VirtualBox to the trash. The 2.4.5 version of Local by Flywheel for Mac is available as a free download on our website. This Mac download was checked by our antivirus and was rated as malware free. The software lies within Developer Tools, more precisely Webmaster Tools. This free software for Mac OS X was originally designed by Flywheel. Local by Flywheel is a free local development environment designed to simplify the workflow of WordPress developers and designers. Download it for free today!
I’ve become a big fan of Local by Flywheel for local WordPress development (i.e. running websites on my Mac). One thing I do find frustrating is the need to SSH into my Local by Flywheel website when I want to run a WP CLI command.
Firefox Download For Mac
Thanks to some great work by Morgan Estes with his project BigWing/Local-WP-CLI, I learned I can run WP CLI commands from my Mac without SSHing into Local by Flywheel (I’ve not tried this on a Windows machine).
If you’re in a hurry to set this up, you can jump to the Quick Setup below.
Configure WP CLI to work without SSH
The key to making this work is adding two files wp-cli.local.yml
and wp-cli.local.php
.
Where to Add These Files
Both of these files go in the project root directory. By default the project root directory for a website called mywebsite, would be ~/Local Sites/mywebsite
. Before adding any files, the contents of the project root directory should be three folders /app
, /conf
, and /logs
. You two new files with be alongside these directories.
What Goes In These Files
wp-cli.local.yml
wp-cli.local.php
The contents of wp-cli.local.php
will vary for each Local by Flywheel website. The information you will need can be found in the Local by Flywheel dashboard for your site under the heading DATABASE.
In my screenshot the relevant values are:
- Remote Host:
192.168.94.100
- Remote Port:
4067
Based on these values, we create the file wp-cli.local.php
with the contents
Confirm WP CLI Works without SSH
To confirm everything is setup correctly from the command line (on your Mac, without SSHing into Local by Flywheel) run:
and if everything is working properly, you’ll get back the URL for your website.
Troubleshooting
My most common error at this point is forgetting to have the website running in the Local by Flywheel Dashboard. We can’t use WP CLI with the site, if the site is not running.
How Does this Work?
WP CLI checks for config files named wp-cli.local.yml
or wp-cli.yml
inside the current working directory (or upwards).
By adding our wp-cli.local.yml
to the project root, any command run anywhere inside the project will use our wp-cli.local.yml
configuration (WP CLI config documentation).
wp-cli.local.yml
We define the path
to the WordPress install in relation to wp-cli.local.yml
and we require the file wp-cli.local.php
be run before any of the WordPress files.
wp-cli.local.php
Download Local By Flywheel
We define the database connection information for connecting to the database from outside Local by Flywheel (this is different than the database credentials found in wp-config.php
because wp-config.php
connects to the database from inside Local by Flywheel). Since our database connection information is set before wp-config.php
, our information is used. Since WordPress tries to set these constants after they are already set, PHP throws notices. To suppress these notices we set PHP to only display fatal run-time errors.
Other Methods to Setup
Quick Setup
Local By Flywheel Reviews
Run this command from the the project root directory of the site.
Google Chrome Download For Mac
Running the following at the command line will:
- download a bash script to create these two files
- run the bash script (you’ll be prompted for the Database host and Database port)
- delete the bash script, leaving the two new files behind
Thanks to Justin Sternberg for sharing his similar quick setup in his Dot-Files.
SSH Into Local by Flywheel
Flywheel Local
While this article is about using WP CLI without SSHing into Local by Flywheel, sometimes you find yourself needing to SSH in for other reasons. I found being unable to directly SSH into a site from the command line frustrating (I wanted to avoid using the Local by Flywheel Dashboard every time I wanted to SSH in). To this end, I created a project on GitHub called SSH into Local By Flywheel. It describes how to create a .dockerid
file in your project root directory with the Docker container name for that site. Once that file is in place you can use sshlbf
to quickly SSH into Local by Flywheel.
As part of this project I’ve also added the command wpcli-lbf-setup
, which is the installation script used in the Quick Setup. If you have this project installed you can use wpcli-lbf-setup
even if you’re not connected to the Internet.