• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

PHP:找不到类"Phar"

用户头像
it1352
帮助1

问题说明

我尝试将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?

正确答案

#1

尝试指定扩展名的路径:

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.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfiebe
系列文章
更多 icon
同类精品
更多 icon
继续加载