Setup WordPress using WP CLI is very comfortable who use WP CLI in their daily development process.
At first you need to have WP CLI installed in you local machine. In order to check, run wp command inside your terminal. Here is what I got running wp command.
NAME
wp
DESCRIPTION
Manage WordPress through the command-line.
SYNOPSIS
wp <command>
SUBCOMMANDS
admin Open /wp-admin/ in a browser.
cache Adds, removes, fetches, and flushes the WP Object Cache object.
cap Adds, removes, and lists capabilities of a user role.
cli Reviews current WP-CLI info, checks for updates, or views defined aliases.
comment Creates, updates, deletes, and moderates comments.
config Generates and reads the wp-config.php file.
core Downloads, installs, updates, and manages a WordPress installation.
cron Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules.
db Performs basic database operations using credentials stored in wp-config.php.
embed Inspects oEmbed providers, clears embed cache, and more.
eval Executes arbitrary PHP code.
eval-file Loads and executes a PHP file.
export Exports WordPress content to a WXR file.
help Gets help on WP-CLI, or on a specific command.
i18n Provides internationalization tools for WordPress projects.
import Imports content from a given WXR file.
language Installs, activates, and manages language packs.
maintenance-mode Activates, deactivates or checks the status of the maintenance mode of a site.
media Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
menu Lists, creates, assigns, and deletes the active theme's navigation menus.
network Perform network-wide operations.
option Retrieves and sets site options, including plugin and WordPress settings.
package Lists, installs, and removes WP-CLI packages.
plugin Manages plugins, including installs, activations, and updates.
post Manages posts, content, and meta.
post-type Retrieves details on the site's registered post types.
rewrite Lists or flushes the site's rewrite rules, updates the permalink structure.
role Manages user roles, including creating new roles and resetting to defaults.
scaffold Generates code for post types, taxonomies, plugins, child themes, etc.
search-replace Searches/replaces strings in the database.
server Launches PHP's built-in web server for a specific WordPress installation.
shell Opens an interactive PHP console for running and testing PHP code.
sidebar Lists registered sidebars.
-- More --
Now its time play around.
Open your server directory from the terminal and run WordPress download command.
wp core download
After successful download process you will get a success message in you terminal. Here is mine.
Downloading WordPress 5.8.1 (en_US)...
md5 hash verified: e885eff6db51b66e448852107f9140de
Success: WordPress downloaded.
Now need to create wp-config file. You have to pass database name, database username and database password through the command. Here is how I set for mine.
wp config create --dbname=phpunittest --dbuser=root --dbpass= --locale=ro_RO
After the successful creation, you will get a message.
Success: Generated 'wp-config.php' file.
Now its time to install the core. You need to pass couple value in this step for your site like url, username, password, admin email. Here is how pass value for mine.
wp core install --url=localhost/wpunittest --title=WP_Unit_Test --admin_user=admin --admin_password=abcd --admin_email=admin@wpunittest.com
Here is the success message for this step.
Success: WordPress installed successfully.
Its time to run WordPress from browser. Run wp admin command from your terminal. It will open admin UI for the first time of you. Place your site username and password there and log in.
wp admin
If you have any thoughts, please do let me know in the commet section. Thanks.