Skip to content

Instantly share code, notes, and snippets.

@saber13812002
Last active May 23, 2024 07:36
Show Gist options
  • Save saber13812002/3a7dee0becc9214d5e63077c67d3dece to your computer and use it in GitHub Desktop.
Save saber13812002/3a7dee0becc9214d5e63077c67d3dece to your computer and use it in GitHub Desktop.
Installing WP-CLI in Windows
WP-CLI is a tool for controlling WordPress through a console window.
thanks to author of this page on wensolutions.com
http://wensolutions.com/installing-wp-cli-in-windows/
For linux : https://www.jetbrains.com/help/idea/using-the-wordpress-command-line-tool-wp-cli.html
Although it is said that wp-cli requires UNIX-like environment (OS X, Linux, FreeBSD, Cygwin) environment however it is still possible to install in Windows environment.
Following are the requirements you should be prepared before begin with wp-cli installation.
1. Install Composer
Download and install the Composer . It will install the latest Composer version and set up your PATH so that you can just call composer from any directory in your command line.
To verify composer installed successfully, try checking its version. for e.g.
C:\Users\username>composer -V
Composer version 1.0.0 2016-01-10 20:34:53
2. Install XAMPP
Install xampp https://filehippo.com/download_xampp/
3. Install Wordpress
download wordpress then extract in C:\xampp\htdocs
4. Install PHP & mysql
You probably have XAMPP already installed PHP and Mysql in your system that already installed the PHP environment.
To verify PHP exist in your system, try checking its version. for e.g.
C:\Users\username>php -v
5. Begin install WP CLI
Once above set up are completed, download phar file.
If wp-cli.phar not exist download from this link
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
6. Bat file
Let’s say you want to install wp-cli in your d: drive, you just go and place this phar file in a logical path d:\wp-cli\wp-cli.phar . Now create a new batch file wp.bat in the same directory, this will act as an alias for the phar file. Inside wp.bat file paste the following contents and save.
@ECHO OFF
php "%~dp0wp-cli.phar" %*
7. Set environment variable
Go to System’s Properties -> click Advanced System Properties -> select the tab labeled Advanced. Click Environment Variables, under the System variables section scroll down to the variable named Path and add ;C:\wp-cli
Exit all CMD’s (or git bash) and reopen them. Now go to one of your WordPress installs and type wp core version. You should get the WP version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment