First of all - great app. Really works like a charm.
I only have an issue with WP cli.
I’m not a terminal ninja but i cd ~/Local\ Sites/lightweb-17/app/public/
but when i run a wp cli command all i get is “Error: Error establishing a database connection”
Any idéa why this is and how i can solove it.
I have tried to change php version, but it didn’t do the trick.
The site is up and running so the DB clearly works
All help highly appreciated.
Kind regards / Oscar
WP-CLI in Local sits in each site container so you need to right-click on the site inside of Local then go to Open Site SSH. Once it opens the Terminal window you can immediately type wp
If you want to use WP-CLI outside of the container then you’ll need to create a wp-cli.yml file that points to the Remote Host and Port shown in the Database tab of the site.
@clay Could you please post an example of what the wp-cli.yml should look like? I’m having trouble getting this to work. I installed wp-cli using Composer and am trying to use the “post-update-cmd” hook to run a wp-cli command. Thanks!
If you’re wanting to run WP-CLI from your computer and not inside the site container, you can try the following:
Open wp-config.php in app/public
Add a conditional for the DB_HOST constant. The value needs to be whatever the “Remote Host” of the database is followed by the “Remote Port” so it’ll look something like:
Hi all, thanks for this thread! I could still use some help getting WP-CLI to work from outside the Local container. I’ve done the wp-config.php setup as recommended by @clay, but I have no idea where to put the wp-cli.yml file that was mentioned or what to put in it. Can anyone share more details?
I have been able to edit my regular config.yml for WP-CLI, but my entries there look like this:
@shortcut:
ssh: user@host
While I can get the host from the Site Setup tab in Local, I cannot find any hint of a user. When I use Local’s built in SSH feature (which is really a docker -exec it appears), it pops me into root. I could try root@host but I have no idea what the Local root password is, and using root seems excessive (the web server files seem to be owned by 501, but that user does not even have a name, much less a password).
If someone could provide a clear example of how to set this up, I would really appreciate it. Thanks!
I am also facing a problem with this. I have made the edits according to the comment by @clay but I’m getting an error connecting to the database. As there was no mention about how to set up the wp-cli.yml (or I just completely missed it), I couldn’t set it up. It would be really nice if you could help a little bit on this. Thanks!
Okay, please scratch that. I was being non-observant and did not replace the original define(‘DB_HOST’, ‘localhost’) statement with what @clay mentioned. It looks like it’s working now. Thanks!
Just one more question though. I am still a beginner so please bear a trivial question. You mentioned a .yml file but the the problem got fixed by just modifying the wp-config.php file. Where does the yml file play a part? Or am I just missing something?
@clay - thanks; is this still valid with Local Lightening? (I’m running 5.0.7). I’ve seen a screenshot showing Remote Host and Port in the Database tab for a site, but these aren’t present in my install. Where would I find these values in 5.0.7?
Yes, good question, this no longer works with Local version 5.x.x (Lightning) as the host and port values have been removed and replaced with a socket value. Any way to get the host/port values returned so we can continue to use this software?