How to reproduce:

  1. "Install" PHP 5.4 (plus ncurses and OpenSSL libraries) from CentOS 7 repositories using rpm2cpio | cpio in a directory called "rpm"
  2. Download phpunit.phar version 4.8.26
  3. Run LD_LIBRARY_PATH=rpm/usr/lib64 rpm/usr/bin/php phpunit.phar

The result:

Fatal error: Class 'Phar' not found in […]/phpunit.phar on line 12

According to the official documentation Phar is "built into" PHP 5.4, whatever "built into" means. There is indeed a rpm/usr/bin/phar and a rpm/usr/bin/phar.phar, but I don't know how to proceed for rpm/usr/bin/php to handle .phar files. There is no phar.so. There is no phar module compiled in according to LD_LIBRARY_PATH=dependencies/rpm/usr/lib64 dependencies/rpm/usr/bin/php -m | grep -i phar. Trying to run phar itself results in this mess:

$ LD_LIBRARY_PATH=rpm/usr/lib64 rpm/usr/bin/php rpm/usr/bin/phar

Warning: stream_wrapper_register(): class 'PHP_Archive' is undefined in […]/rpm/usr/bin/phar.phar on line 6

Warning: include(): Unable to find the wrapper "phar" - did you forget to enable it when you configured PHP? in […]/rpm/usr/bin/phar.phar on line 9

Warning: include(): Unable to find the wrapper "phar" - did you forget to enable it when you configured PHP? in […]/rpm/usr/bin/phar.phar on line 9

Warning: include(phar://[…]/rpm/usr/bin/phar.phar/phar.inc): failed to open stream: No such file or directory in […]/rpm/usr/bin/phar.phar on line 9

Warning: include(): Failed opening 'phar://[…]/rpm/usr/bin/phar.phar/phar.inc' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in […]/rpm/usr/bin/phar.phar on line 9
Neither Extension Phar nor class PHP_Archive are available.

I would like to avoid installing a whole suite of tools (PEAR, Composer) because that would make portability an even bigger problem than it is.

There doesn't seem to be any separate packages available for Phar. After installing epel-release the only package matching phar is php-seld-phar-utils, and that doesn't seem to contain any relevant files:

# rpm --query --list php-seld-phar-utils
  • Possibly related: stackoverflow.com/questions/30304470/… – superuser0 Dec 29 '16 at 17:51
  • Try LD_LIBRARY_PATH=rpm/usr/lib64 rpm/usr/bin/php -d extension=phar.so phpunit.phar. If it works, you need to make some changes (extension=phar.so) in your php.ini file (probably related to CLI) and restart your web server. – Farahmand Dec 29 '16 at 21:53
  • @Farahmand Nope. There is no phar.so anywhere (as I already wrote; I checked the entire machine), and it says so. And I have neither a php.ini nor a web server. – l0b0 Dec 29 '16 at 22:03
  • @superuser0 Doesn't look like it, unfortunately, but thanks for the tip. I've updated the question. – l0b0 Dec 29 '16 at 22:11
  • Could you mention that which version of PHPUnit has been downloaded? – Farahmand Dec 29 '16 at 22:29

Your Answer

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

Browse other questions tagged or ask your own question.