1

I'm trying to install the WP-CLI tools as described here using Cygwin, which the guide claims is supported.

When doing:

cd /XAMPP/htdocs
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info

It fails with the following error:

PHP Fatal error: Uncaught Error: Class 'Phar' not found in /cygdrive/b/Users/User/Desktop/XAMPP/htdocs/wp-cli.phar:3 Stack trace: #0 {main} thrown in /cygdrive/b/Users/User/Desktop/XAMPP/htdocs/wp-cli.phar on line 3

What's causing this error, and how can I successfully get WP-CLI running under Cygwin?

3

You are missing the Phar extension or it's not enabled. Which version of PHP are you actually running? Check it with php --version.

The Phar extension is bundled with PHP as of PHP version 5.3.0, and enabled by default.

See https://www.php.net/manual/en/phar.installation.php.

Your best bet is to upgrade PHP to at least PHP 7.1. Alternatively follow other guides around here to either get and enable Phar, or calling WP-CLI with a different PHP version.

See PHP: Class 'Phar' not found.


Finally this one may turn out as a big helper as well: Cygwin and Xampp, wrong PHP is being used. To have Cygwin use XAMPP's PHP instead its own call the following command every time you restart Cygwin or add it to its ~/.bashrc or ~/.bash_profile to be permanent.

export PATH=/cygdrive/c/xampp/php:$PATH
  • Thank you, it did turn out that the issue was that I was using Cygwin's own PHP rather than XAMPP's; however, even with this rectified, I'm still getting a separate error that doesn't allow me to run WP-CLI from anywhere except the directory it's contained in. I've created a question here for that error: wordpress.stackexchange.com/questions/340648/…. – Hashim Jun 17 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.