Start site through command line

If you have the WP CLI command installed on your computer (like via Homebrew), you can add two files to the root folder for the local site that enable using the WP CLI directly from the shell on your regular computer, without even going into the shell of the local site, so long as your CWD is within the folders of the local site.

One is wp-cli.local.yml:

path: app/public
require:
  - wp-cli.local.php

The second is wp-cli.local.php:

<?php
define('DB_HOST', ‘192.168.95.100:XXXX');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');

error_reporting(0);
@ini_set('display_errors', 0);
define( 'WP_DEBUG', false );

Just replace XXXX with the port for the DB that is shown in the main Local window.

I find that this is even more convenient than going into the local machine’s shell if all I’m trying to do is use the WP CLI. In fact, another feature request, I guess, could be Local just creating these files for us on new sites.

2 Likes