wp-cli/server-command

Easy WordPress development server

bburky opened this issue · 2 comments

I wrote this recently without knowing about wp-cli:
https://gist.github.com/bburky/9317876

It works quite well for quickly setting up a development server without MySQL (which yes, I'm aware is unsupported).

I tried to set up the same environment using wp-cli, but it seems to be necessary to do a lot of the installation manually because a MySQL server is not available:

wp core download

# This actually needs MySQL running, can't use this
# Really just need a default configuration, the database settings will be ignored
# wp core config --dbname=wp --dbuser=wp --dbpass=pass

# Use this instead
# It would be nice to still set the salts automatically somehow though
cp wp-config-sample.php wp-config.php

# This doesn't work, it tries to connect to MySQL and fails
# wp plugin install sqlite-integration

# Use this instead
cd wp-content/plugins
curl -O https://downloads.wordpress.org/plugin/sqlite-integration.1.5.zip
unzip sqlite-integration.1.5.zip
rm sqlite-integration.1.5.zip
mv sqlite-integration/db.php ../
cd ../../

wp core install --title=Dev --admin_name=admin --admin_email="admin@example.com" --admin_password=pass --url="http://localhost:8080/"

wp server

Once db.php is patched everything works fine. Is there any easy way to install the plugin and the initial wp-config.php configuration without accessing MySQL?

If this workflow is easy enough, it is a very nice way to do plugin or theme development as long as nothing MySQL-specific is needed.

(Should I raise any of these issues at https://github.com/wp-cli/wp-cli instead?)

Hello,

Yeah, this is definitely the wrong place to ask. wp server just deals with serving the files (i.e. replacing Apache or Nginx). It assumes that everything is already configured.

Anyway,

wp core config doesn't need MySQL; it just checks if the credentials passed actually work. I suppose we could add a --skip-check flag. See wp-cli/wp-cli#1060

As for installing the db.php file, you couldn't do that even with a wp plugin download command, so I think you're better off using straight bash instead.

Ah, ok then. Thanks for creating an in issue at wp-cli too. I guess all I'm asking for is wp core config --skip-check then.

wp server is very nice for development, and using SQLite makes it even easier.