phpphar

PHP: Class 'Phar' not found


I try to use the Silex framework as base for my web application. However, if I try to include the *.phar archive, PHP throws the following error:

Fatal error: Class 'Phar' not found in /var/www/framework/silex.phar on line 11

The following relevant lines are in my /etc/php/php.ini (as suggested in the docs of Silex):

extension=phar.so
phar.readonly = Off
phar.require_hash = Off
detect_unicode = Off

The PHAR library is present in /usr/lib/php/modules/phar.so which is set as the extension path for all libraries in my php.ini

Does anyone know why PHP is throwing this error?


Solution

  • Try specifying the path to the extension:

    php -d extension=phar.so composer.phar <your_script>
    

    Other options:

    Based on the information you provided, there are a few possibilities: