- Code: Select all
https://github.com/wp-cli/wp-cli
to my Windows box to
- Code: Select all
D:\WEBDEV\WP-CLI
and added
- Code: Select all
D:\xampp\mysql\bin;D:\xampp\php
to the Windows Path.
Being in
- Code: Select all
D:\WEBDEV\WP-CLI
I can open a command prompt and type
- Code: Select all
php wp-cli.phar --info
and it will correctly show me:
- Code: Select all
D:\WEBDEV\WP-CLI>php wp-cli.phar --info
PHP binary: D:\xampp\php\php.exe
PHP version: 5.6.8
php.ini used: D:\xampp\php\php.ini
WP-CLI root dir: phar://wp-cli.phar
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.19.2
D:\WEBDEV\WP-CLI>
Now I have various work folders with WP installations where I would like to use the WP-CLI.
Though this also implies that I have to copy the wp-cli.phar file into every one of those folders and when wanting to use it always prepend PHP to the command.
What I am trying to do is have the xyz.phar file and its commands available from any location in the system or at least from anywhere on partition D:\.
So for example I have one WP installation in
- Code: Select all
D:\work\wp1\
- Code: Select all
F:\work_work_always_work\wp3\
Now I simply like to open the command prompt/CLI in the root of these WP installations and for example type
- Code: Select all
wp-cli --info
and it should display me info similar to above and ideally I can then also run other commands from the wp-cli.phar on that WP installation/root.
I have done research about this before asking here.
So far I have come to read
- Code: Select all
https://trepmal.com/2014/02/22/getting-started-with-wp-cli/
https://stackoverflow.com/questions/10753024/how-to-access-the-command-line-for-xampp-on-windows
https://stackoverflow.com/questions/11082337/how-to-make-an-executable-phar
https://superuser.com/questions/737602/run-script-from-powershell-in-the-same-window
The last link in that list of links suggests making a .bat file and linking the .phar file to the local PHP install.
Upon exploring the php dir of my XAMPP portable 5.6.8-0-VC11 install I find such .bat files, one in particular
- Code: Select all
phar.phar.bat
In that file I find
- Code: Select all
"%~dp0php.exe" "%~dp0pharcommand.phar" %*
and this seems terribly close to what is mentioned in the last link from the list of links above.
But when I create a
- Code: Select all
wpcli.bat
file and put
- Code: Select all
"%~dp0php.exe" "D:\WEBDEV\WP-CLI\wp-cli.phar" %*
I cannot seem to run the wp-cli.phar from a command prompt opened in D:\ for example.
What do I need to write exactly to link this wp-cli.phar file to php in my portable XAMPP install please?
How could I possibly "rename" the command from
- Code: Select all
php wp-cli.phar [option]
to something like
- Code: Select all
wp [option]
please?
I would be super happy if you can point me in the right direction or have further links that would lead to a solution.
Thank you for your help.