Step-by-Step Guide: Creating a WordPress Website Locally with Valet and WP-CLI
Make sure Valet and WP-CLI are installed on your system.
Create your Local website directory and enter it – (Set a directory name)
mkdir gb-starter && cd gb-starter
Download WordPress core files –
wp core download
Set database configuration on the wp-config file ( change DbName, DbUser, DbPass ) as you want –
wp core config --dbname=change-db-name --dbuser=root --dbpass= --dbhost=localhost
Create a Database as per the above configuration of the wp-config file –
wp db create
Install WordPress (Set URL, Title, UserName, Password, and Email) –
wp core install --url=http://gb-starter.test --title="Guternberg Starterkit" --admin_user=admin --admin_password=admin [email protected]
Check Database tables –
wp db check
Create a Valet Link to make the directory browsable –
valet link
Set WP_DEBUG and WP_DEBUG_LOG to true for the Dev environment
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
Check the installed plugins list –
wp plugin list
Delete unwanted plugins –
wp plugin delete akismet
wp plugin delete hello
// Open code in VSCode
code .
Browse the site with your default browser –
valet open
Remove directory (remove default plugin)
rm -r DirName
Revmove File
rm -rf FileName
To add SSL
valet secure
To remove SSL:
valet unsecure
Destroy the site:
valet destroy
Thank you for this detailed guide! Could you please explain the benefits of using Valet with WP-CLI for local WordPress development compared to other local development tools like XAMPP or Local by Flywheel?
Thank you for your question.
On macOS, Valet and WP-CLI offer a lightweight, fast, and scriptable development experience. There are no VMs or Docker containers required, allowing for instant site setup with low CPU usage. Features like valet park and valet secure provide automatic routing and HTTPS.
Switching PHP versions is easy, and WP-CLI automates installs and updates across projects.
In contrast, XAMPP and Local are heavier and GUI-focused, making them suitable for beginners but slower and less scriptable.
In summary, choose Valet and WP-CLI for terminal speed, and Local for a user-friendly GUI on Windows.