I was setting up my wordpress development environment in windows today. I wanted to have php unit tests for the plugin I have been developing for a few days, and I ran into an article which says wp-cli.phar cannot be used in windows! The article was about using PHPUnit to write wordpress plugin unit tests.
Okay, PHAR is just a php application in an archived folder. If it’s made as executable, it should run on windows, too. So, I figured out how to install wp-cli in windows.
So, I tried this:
- Create a directory for PHP binaries; e.g.,
PATHenvironment variable (related help)
- Download wp-cli.phar and save the file as
- Open a command line (e.g., press Windows+R » type
- Create a wrapping batch script (results in
echo @php "%~dp0wp-cli.phar" %* > wp.cmd
- Open a new command line and confirm that you can execute WP CLI from any path:
And it WORKS.
The idea totally came from the steps of installing PHPUnit in windows. Nothing special, just a curiosity led to the solution.