-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Run commands against the Local environment from the host #5
Comments
You don't actually need this CLI to change at all in order to do that sort of thing. Use the existing Installing the WP-CLII recommend using Homebrew to install the WP-CLI globally on your system. Use Configuring Local CLI Access to SitesIn the root folder of your Local site (the folder that contains the
path: app/public
require:
- wp-cli.local.php
<?php
define('DB_HOST', 'localhost:SOCKET_PATH');
error_reporting(0);
@ini_set('display_errors', 0);
define( 'WP_DEBUG', false ); Replace UsageSimply |
@alexclst The Windows version of Local doesn't show the socket. Somewhere else one could find that? |
@ethanclevenger91 the Windows version may use Host and Port instead of Socket, at least based on what my MySQL config file shows where it splits between Windows and everything else. So perhaps you need to use those, where the |
@alexclst that works, which is nice and all, but it isn't really the same thing. We're now talking to the right database from the host machine, but this still results in a world where my host might be running PHP 8.0, while my Local site might be on PHP 7.4. Ideally, we'd be running commands against the environment hosting the site, which I presume is a Docker container. If this weren't baked into Local CLI, it'd be nice to have instructions for configuring a WP-CLI alias in wp-cli.local.yml:
|
@ethanclevenger91 I am pretty sure that Local is no longer Docker-based at all, ever since VirtualBox was dropped as a dependency back in v5 or so years ago. In fact, I can observe the site packages (nginx, mysqld, etc.) right within Activity Monitor on macOS, which shows that they are run right on the bare macOS operating system, no VM in between. The equivalent app on Windows can probably show the same. PHP versions are indeed a problem. Luckily I rarely get bitten by it, but still. I've tried to set up a multi-version PHP environment on my Mac a few times, similar to what tools such as |
Ah, right. Yeah that's essentially what's happening when Local boots a CLI window. There's a script that runs that loads that site's PHP version onto the path. So in that sense, the WP-CLI alias solution doesn't make any sense. A local-cli command that could determine the current site's ID (or be explicitly passed it) and do the same stuff that script does, and then revert back, would be an ideal solution here I think, which is the original request anyway. |
Having this would be awesome. I'm thinking of uses like popping up the local wp cli in the shell of your IDE with a single hotkey (VSCode, Vim, etc). |
While waiting for an official solution, I created a custom bash script that allows me to start, stop and open site shells. Requirements
Script#!/bin/sh
COMMAND=$1
SITE=$(local-cli list-sites | gum filter)
SITEID="$(echo ${SITE} | awk -F '│' '{print $2}' | awk '{$1=$1};1')"
case $COMMAND in
shell)
~/Library/Application\ Support/Local/ssh-entry/${SITEID}.sh; exit
;;
start)
local-cli start-site ${SITEID}
;;
stop)
local-cli stop-site ${SITEID}
;;
*)
esac |
In an effort to automate as much of running client updates each month as I can, I currently have a script that will crawl through a configured list of directories and, in each one, essentially run
wp plugin update --all
(or other arbitrary shell commands). That can run for an hour or whatever and then I pop into each site, give it a once over, commit my changes and push. Great.I've considered moving to Local for development, but would need some kind of feature out of
local-cli
that let's me execute commands against a site. Something likewp-cli
itself provides for running commands over an SSH connection.Would love to see a similar feature come to
local-cli
. Something like...The text was updated successfully, but these errors were encountered: