Total Pageviews

Saturday 28 November 2020

wp-cli-valet-command

 Harness the power of Laravel Valet for creating fully functional WordPress installs in seconds.

https://aaemnnost.tv/wp-cli-commands/valet/

White-glove services for turn-key installs in seconds.

Travis Build Packagist

Quick links: Using | Installing | Troubleshooting | Support 

Using

This package implements the following commands:

wp valet new

Create a new WordPress install -- fast

wp valet new <name> [--project=<project>] [--in=<dir>] [--version=<version>] [--locale=<locale>] [--db=<db>] [--dbname=<dbname>] [--dbuser=<dbuser>] [--dbpass=<dbpass>] [--dbprefix=<dbprefix>] [--admin_user=<username>] [--admin_password=<password>] [--admin_email=<email>] [--unsecure] [--portable]

This command will spin up a new WordPress installation -- complete with database and https ready-to-use in your browser faster than you can put your pants on.

OPTIONS

<name>
	Site domain name without TLD. This will become the directory name of the project root.
	Eg: To create an install for example.dev, `wp valet new example`

[--project=<project>]
	The WordPress project to install. Choose from any project supported by Laravel Valet.
	---
	default: wp
	options:
	  - wp
	  - bedrock
	---

[--in=<dir>]
	Specify the path to the parent directory to create the install in.
	Defaults to the current working directory.

[--version=<version>]
	WordPress version to install.
	---
	default: latest
	---

[--locale=<locale>]
	Select which language you want to install.

[--db=<db>]
	Database driver to provision the site with.
	---
	default: mysql
	options:
	  - mysql
	  - sqlite
	---

[--dbname=<dbname>]
	Database name (MySQL only).
	Defaults to 'wp_<name>'.

[--dbuser=<dbuser>]
	Database User (MySQL only).
	---
	default: root
	---

[--dbpass=<dbpass>]
	Set the database user password (MySQL only).
	---
	Default: ''
	---

[--dbprefix=<dbprefix>]
	Set the database table prefix.
	---
	default: 'wp_'
	---

[--admin_user=<username>]
	The username to create for the WordPress admin user.
	---
	default: admin
	---

[--admin_password=<password>]
	The password to create for the WordPress admin user.
	---
	default: admin
	---

[--admin_email=<email>]
	The email to use for the WordPress admin user.

[--unsecure]
	Provision the site for http rather than https.

[--portable]
	Provision the site to be portable. Implies --unsecure and --db=sqlite.

wp valet destroy

Completely remove an installation.

wp valet destroy <name> [--yes]

This will drop the database, and delete all of the files as well as remove any self-signed TLS certificate that was generated for serving this install over https.

OPTIONS

<name>
	Site domain name without TLD. It should match the directory name of the project root.

[--yes]
	Pre-approve the confirmation to delete all files and drop the database.

Installing

This command leverages Laravel Valet -- an open source development environment for Mac + *nix minimalists.

It runs various commands lightning fast, allowing you to spin up a site in your browser immediately after creating it, without any other configuration, all from a single command.

You should also understand how Valet works, especially the portion on Serving Sites.

Environment Setup

  1. MacOS users should install Homebrew first.

  2. Follow the Valet installation instructions on the Laravel documentation to get started.

Note: Linux users should use Valet-linux instead, a fork of the original project that shares most of the same valet commands powering this wp-cli plugin.

  1. Confirm your wp-cli environment works and meets the minimum version specified below by running wp cli info and proceed if the output looks something like:
PHP binary:	/usr/bin/php7.0
PHP version:	7.0.22-0ubuntu0.16.04.1
php.ini used:	/etc/php/7.0/cli/php.ini
WP-CLI root dir:	phar://wp-cli.phar
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/home/user/wp-cli-valet-command
WP-CLI packages dir:	/home/user/.wp-cli/packages/
WP-CLI global config:	/home/user/.wp-cli/config.yml
WP-CLI project config:	
WP-CLI version:	1.4.1

Update, if needed, to the latest stable release with wp cli update.

Loading the wp-cli-valet-command package

Installing this package requires WP-CLI v1 || v2 or greater. Update to the latest stable release with wp cli update.

Once you've done so, you can install this package with:

wp package install git@github.com:aaemnnosttv/wp-cli-valet-command.git

Troubleshooting

Error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' The installer halts at the database creation stage because it doesn't have a password for your local MySQL instance.

Prevent this from happening by appending your wp valet commands like such: wp valet new site --dbpass=local_root_password.

At this point, you can:

  1. Either create a wp-config.php file manually,
  2. use wp configcommand to have wp-cli create one for you, or
  3. use wp valet destroy site and try running your wp valet new command again, this time using the --dbpass attribute.

Configuring Alternate Defaults

As with other wp-cli commands, you can set default attributes when running wp valet.

Simply add the appropriate details in ~/.wp-cli/config.yml:

valet new:
  ## Uncomment or update the relevant lines when necessary to set your own defaults.
  project: 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: # 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

The wp valet new defaults are shown here as an example for clarity.

One simple usage for the config.yml could look like

valet new:
  dbuser: root # or any db creating user
  dbpass: password # set yours here

to enable wp valet new site to spin up a full, live, running local WordPress site in ~3 seconds without any additional parameters.

Support

Github issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support

from https://github.com/aaemnnosttv/wp-cli-valet-command

相关帖子:https://briteming.blogspot.com/2020/11/sqlitewordpresswordpress.html

No comments:

Post a Comment