I assume that you already know what is wp-cli tool, in this post I am going to show you how to download and install wp-cli tool on Windows 10. However, if you have Windows 7 or Windows 8; these steps will work for you.
You need to have PHP and Composer installed and set them to system PATH. I have installed XAMPP and set PHP and MySQL to system PATH and installed Composer separately.
Please make sure that you are able to check PHP and Composer version from command line tool.
- How to Install PHP, MySQL and Apache on Windows 10
- How to Install WordPress on Windows 10
- How to Install Composer on Windows 10
Download and Install WP-CLI for Windows
Once you have installed PHP and Composer and set them to system PATH;
- Download wp-cli.phar
- Create a folder c:\wp-cli
- Copy and Paste downloaded wp-cli.phar file in c:\wp-cli
- Create a named wp.bat in c:\wp-cli folder
- Paste the following code in wp.bat file and save wp.bat file
@ECHO OFF php "c:/wp-cli/wp-cli.phar" %*
Set c:\wp-cli to your system PATH
From Windows Menu, open Environment Variables and select Path and click EDIT and ADD new environment variable and hit ok, ok, and ok.
Relaunch CMD & Type wp help
WP CLI Commands
Now you can run wp cli commands to manage WordPress sites and scaffold plugins, blocks, and themes. Now, install WordPress on Windows, navigate to your WordPress installation directory and try the following wp cli commands.
- wp scaffold plugin plugin_name
- wp plugin install user-switching –activate
- wp cli version
- wp scaffold _s theme-name
- wp scaffold post-type books
- wp scaffold block movie
- wp scaffold child-theme xyz_child parent_theme=xyz
For more wp-cli commands visit official docs’ page