[Tutorial] How to add wp-cli to Laragon


  • administrators
    | 87280 points

    Adding additional command line tool like wp-cli to Laragon is easy. We will use C:\laragon\usr\bin to store our tool. Here's how:

    1. Download wp-cli.phar and put it to C:\laragon\usr\bin\wp-cli.phar
      https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

    2. Create a file called wp.bat in C:\laragon\usr\bin\wp-cli.phar with following content:

    @ECHO OFF
    php "%~dp0wp-cli.phar" %*
    

    That's all folks!


    To test, open Laragon's Terminal (CTRL + ALT + T), and type:

    wp --version
    

    You should see something like this: WP-CLI 1.5.1

    To check info, type:

     wp --info
    

  • administrators
    | 87280 points

    Or you can do the lazy way (paste it in Laragon's Terminal) and enter:

    cd C:\laragon\usr\bin && curl -L -O https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&  echo @ECHO OFF > wp.bat && echo php "%~dp0wp-cli.phar" %* >> wp.bat
    
    

  • | 2092 points

    Should I add C:\laragon\usr\bin to the PATH variable in order to use it from the normal windows command prompt/GIT bash?


  • administrators
    | 87280 points

    No, you should not. Because you also need to add PHP to PATH.
    You may think it is not a matter. However, what if you want to change to another PHP version in the future?
    Doing things like that in a long term will pollute your PATH.

    Laragon's Terminal manages PATH for us. Therefore, we can add another PHP, Apache, Nginx, Node.js, Ruby, Python, Golang, Java, MongoDB, PostgreSQL,... without any headache :)


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.