Despite working for a different hosting company with another local development option, I was using Local for local WordPress development for years before joining Pantheon, and I recently was trying to get it working again since upgrading to the latest version. With Local 3, I learned this neat trick from Sal Ferrarello for using WP-CLI outside of the container, but the setup changed a bit when I moved to 6.0.
Socket Path
Local no longer has you SSH into the container to use WP-CLI, but the “open site shell” option in the drop-down menu instead sets up all the various environmental variables needed to use WP-CLI, but it’s annoying to have to go through the Local GUI every time.
We’ll follow the same instructions in Sal’s configuration to setup wp-cli.local.yml
and wp-cli.local.php
, but instead of looking for the remote host and remote port in Local’s database tab, we need the path to the mysqld.sock
file.
With that path, we can update our DB_HOST constant in in wp-cli.local.php
like so:
<?php define('DB_HOST', 'localhost:/Users/philiptyler/Library/Application Support/Local/run/Nn6ehKT-l/mysql/mysqld.sock');
You can confirm WP-CLI works without SSH by running a sample command in your project directory:
$ wp option get siteurl
and you should get your site’s URL back successfully.