I’m currently experimenting with WP-CLI (http://wp-cli.org) – I have finally managed to get it to run on my basic command line by downloading/moving it to a PATH variable directory (i.e C:xamppphp) and then updating my PATHSPEC to include .PHAR.
I have renamed the original file from wp-cli.phar to wp.phar in order to be able to reference it as wp in my cmd.exe.
Prior to this method I installed wp-cli using CURL and chmod in my Git Bash installation then renaming the file to wp (without an extension) and adding the path containing file to the PATH variable. This caused the .PHAR file to work in Git Bash but not to work on the command line.
MY ISSUE:
Whenever I try to use my wp.phar in the native CLI I get a php error report – it does recognise the command and does show a list of suggestions (which is usually given when syntax is incomplete or incorrect).
How do I even start to figure this out?
1 – I’ve attempted to look for a git batch file in my Git Bash directory to see if I can find a dependency I’m missing but no dice.
2 – My Git Bash is now not recognizing the wp
command and I now need to refer to wp.phar
and then add any sub-commands/arguments after. However using the Git Bash CLI wp.phar
doesn’t cause errors
After a few months I found a solution.
CMD Line Options (Run as Administrator):
assoc .php=phpfile
andassoc .phar=pharfile
Next is adding the program that opens this file. Adding an ftype command allows us to open .php/.phar files without using the
php
.ftype pharfile=php.exe %1 %*
(The %1 is a placeholder for the file called and %* refers to any other arguments that many be input).FINALLY
The key issue was getting the .phar scripts to execute in the command line as windows ends up trying to open these files in it’s Open With Dialog
So what I did was wrap my .phar in a batch file with this command (in the same folder as the phar
echo php "%~dp0wp-cli.phar" %* > [name of file].cmd
I then run this file as [name of file] with any arguments and it works as usual.