I’m a Mac or Linux guy when it comes to my dev platform. I’ve used from scratch LAMP stacks, at work we use MAMP Pro and on my personal Mac I use docker and Devil box. I’ve moved to this type of product because it makes getting things set up so much faster and managing multiple sites (mostly WordPress) so much easier. I recently picked up a Microsoft Surface Go to have the smallest computer I could find with a plan to put linux on it. It worked but not completely so I moved back to Windows 10.

I gave WSL a try but I feel like it looses some of the efficiency I’ve grown to expect with my other setups, enter WAMP. So far I like it, it’s not as elegant as my other environments but in some ways it’s better. So now I have my stack, but now I need the rest of my tools including WP-Cli. Let’s get things working on Windows 10.

The Basics

To understand the issue you have to realize that the WP-Cli works natively on Linux and bash. The commands that you usually run to make things work don’t work on Windows so we need to create some work-arounds to allow us to use the tool fully. None of the tutorials I’ve seen worked with database commands if they got things working at all and that will be covered in my next post.

Start with:

  • Install WAMP including PHP and MariaDB.
  • Download wp-cli.phar from here: https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  • Create a directory in the root of c: called wpcli and copy wp-cli.phar to it. The file path will be c:\wpcli\wp-cli.phar
  • Create another file called wp.bat in this folder and edit it with notepad to include the following:
php “c:\wpcli\wp-cli.phar” %*

Setting The Paths

We will need to set a few paths which will allow you to run a command from that folder without being in that folder via command line. To do this navigate to Advanced System Settings > Environment Variables > Path and click new. Add the following:




You probably understand what the path option offers in Windows but, this will allow commands to be run from c:\wpcli without needing to be in that directory so when we type wp it runs wp.bat. But there is more to this setup that needs to happen. Notice that the script we wrote in wp.bat runs php before the wp-cli.par file. Php also needs to be able to run from any folder. Since we are using WAMP for this setup we want to run the php that was installed with WAMP which is my preference.

For me this was version php7.3.12 found in C:\wamp64\bin\php\php7.3.12 so I added that path to my environment variables as well. Notice it in the screenshot above.


Once added you can launch cmd or Command Prompt and type the following and you should see the version of php you added to the environmental path.

php --version

You can now test that your wp command works by typing wp and seeing the manual page for the WP-Cli. (Press Ctrl-C then “y” to exit that screen.)


You can now use the WP-Cli tools on Windows 10 with WAMP (make sure WAMP is running). This is where all other tutorials ended and the job is only half done. All commands except the ones dealing with the database can be run by using wp from any directory via the command prompt. To get something like “wp db import” to work for instance requires a mysql command to be sent to the database that we can’t access without some additional tweaks. Find out how to complete this in our next article.

Please let us know if you enjoyed the tutorial of if you ran into any issues in the comments section below!

Article Tags:
· · ·
Article Categories:

Web developer and former photographer by trade...gamer and all around tech enthusiast in his free time. Christoph started sdatic.com as a way to organize his ideas, research, notes and interests. He also found it enjoyable to connect and share with others who parallel his interests. Everything you see here is a resource that he found useful or interesting and he hopes that you will too.

Leave a Reply

Your email address will not be published. Required fields are marked *