Search code examples
phpwordpressxamppwp-cli

Use different php.ini for wp-cli.phar in XAMPP


I trying to use the wp-cli for wordpress in XAMPP:

I downloaded wp-cli.phar into wordpress directory in XAMPP in ubuntu 16.04

/opt/lampp/htdocs/wordpress/

prompting php wp-cli.phar

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

and checking the info: php wp-cli.phar --info

PHP binary: /usr/bin/php7.0
PHP version:    7.0.8-0ubuntu0.16.04.2
php.ini used:   /etc/php/7.0/cli/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI packages dir:    
WP-CLI global config:   
WP-CLI project config:  /opt/lampp/htdocs/wordpress/wp-cli.local.yml
WP-CLI version: 0.25.0

I notice that I'm not using the PHP installed inside XAMPP.

How can I change those wp-cli.phar path to use the php.ini in /opt/lampp/etc ?


Solution

  • Your output still looks like wpcli is using the php in your system rather than the php form xampp.

    To make wpcli work with xampp you need to to define the following rules in the .profile file located in your home directory:

    Step 1:

    nano ~/.profile (or open your .profile with whatever editor you are              confortable with)
    

    step 2: Add the following code at the very top of your .profile

    # Define path for XAMPP
    XAMPP_PATH=/opt/lampp/bin:/opt/lampp/sbin
    export PATH="$XAMPP_PATH:$PATH"
    

    Step 3: save (CTRL + O in nano and CTRL + X to exit/close)

    Step 4: Run the source command to read, and execute the new PATH variable set in the .profile file.

    $ source ~/.profile
    

    Step 5: type wp --info and check the output. it should work perfectly with xampp this is actually my setup for Wordpress development.