PHP:找不到类"Phar"
我尝试将Silex框架用作Web应用程序的基础.但是,如果尝试包含* .phar存档,PHP会引发以下错误:
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
以下相关行在我的/etc/php/php.ini
中(如Silex的文档中所建议):
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
PHAR库位于/usr/lib/php/modules/phar.so
中,该库设置为我的php.ini
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
有人知道为什么PHP会引发此错误吗?
Does anyone know why PHP is throwing this error?
尝试指定扩展名的路径:
php -d extension=phar.so composer.phar <your_script>
其他选项:
根据您提供的信息,有几种可能性:
Based on the information you provided, there are a few possibilities:
-
您正在使用其他php.ini.检查
phpinfo()
的输出进行确认,并确保您正在编辑活动目录.
You are using a different php.ini. Check the output of
phpinfo()
to confirm, and ensure that you are editing the active one.
/usr/lib/php/modules/phar.so不可读.确保Web服务器用户可以读取此文件.
/usr/lib/php/modules/phar.so is not readable. Ensure that the web server user can read this file.
自从您上次将与phar相关的信息添加到php.ini中以来,您的Web服务器尚未重新启动.重新启动您的网络服务器.
Your web server has not been restarted since you last added the phar-related information to php.ini. Restart your webserver.