Anyone using Valet+ with wp-cli valet?

I recently got turned on to Valet+ from a DeliciousBrains blog article.

I’m just getting started and found my way into Ben Word’s article about using Valet with Bedrock.

It includes a reference to a wp-cli add-on that looks really useful: WP-CLI Valet Command | Evan Mattson.

However it doesn’t seem to play well with valet+. I’m getting the following errors:

$ wp valet new demo

Don't go anywhere, this should only take a second...

**Error:** ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

And using the --project flag with bedrock:

$ wp valet new my-project --project=bedrock
Don't go anywhere, this should only take a second...
Error: 
                                                                          
  [Seld\JsonLint\ParsingException]                                        
  "./composer.json" does not contain valid JSON                           
  Parse error on line 1:                                                  
                                                                          
  ^                                                                       
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['   

Input, as always, hoped for…

As per the wp-cli valet README, the “Access Denied” error is because wp-cli needed a password to connect to the local (brewed) mysql.

I didn’t have one set as was able to login to mysql as root without one:

mysql -uroot
# 

So I set one: $(brew --prefix mysql)/bin/mysqladmin -u root password apassword

Now I can spin up WP sites like:

wp valet new site --dbpass=apassword
Don't go anywhere, this should only take a second...
Success: site ready! https://site.test

Loading over https, too!

I even added the password to ~/.wp-cli/config.yml and now don’t need to add the flag.

Now I have updated the configuration and project: bedrock is working, too.

1 Like

On one computer the ~/.wp-cli/config.ymlwas automatically populated, I guess by wp valet. In case not here’s default:

valet new:
 ## Uncomment or update the relevant lines when necessary to set your own defaults.
 project: bedrock # wp # or bedrock
 # in: # override - defaults to current directory
 version: latest
 # locale:  # use if not English
 db: mysql # or sqlite
 # dbname: # defaults to wp_name
 dbuser: root # or any other local user capable of creating databases (MySQL only)
 dbpass: your_password # enter the appropriate password if necessary (MySQL only)
 dbprefix: wp_
 admin_user: admin
 admin_password: admin
 ## Boolean options can also be configured, too.
 # unsecure: false # set to true to override
 # portable: false # set to true to override