找不到类"PharData" [英] Class 'PharData' not found

查看:208
本文介绍了找不到类"PharData"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产服务器(CentOS 5.4和php 5.3.5)上收到此错误:

I get this error on my production server (CentOS 5.4 and php 5.3.5) :

警告:include_once(PharData.php):无法打开流:否这样 /var/www/ZendFramework/library/Zend/Loader.php中的文件或目录 第146行

Warning: include_once(PharData.php): failed to open stream: No such file or directory in /var/www/ZendFramework/library/Zend/Loader.php on line 146

警告:include_once():无法打开"PharData.php"进行包含 (include_path ='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php') 在第146行的/var/www/ZendFw/library/Zend/Loader.php中

Warning: include_once(): Failed opening 'PharData.php' for inclusion (include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php') in /var/www/ZendFw/library/Zend/Loader.php on line 146

致命错误:找不到"PharData"类 /var/www/vm/app/Backup.php,第40行

Fatal error: Class 'PharData' not found in /var/www/vm/app/Backup.php on line 40

这是失败的代码:

$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");

此代码在我自己的计算机上正常工作.

This code is working fine on my own computer.

默认情况下,php 5.3+中应包含PharData ...

PharData should be included by default in php 5.3+ ...

感谢您的帮助!

更新:

我正在使用Zend Auto loader功能使用此代码来加载良好的php文件:

I am using the Zend Auto loader feature to load the good php files using this code :

require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

Zend自动装带器正在执行include_once(PharData.php).

Zend autoloader is doing the include_once(PharData.php).

推荐答案

仅仅因为Phar在PHP 5.3中是默认捆绑的,并不意味着它一定包含在您的安装中.使用./configure构建PHP时,可以通过--disable-phar禁用Phar扩展.

Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.

要确认这一点,请运行以下脚本:

To confirm this, run the following script:

<?php
  phpinfo();
?>

首先出现的部分之一是Configure Command部分.查看本节以查看是否存在--disable-phar开关,以及该页面上通常是否有Phar节.

One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.

如果不存在,则需要联系您的主机以将其启用.但是,他们很有可能不会为您做这件事,因为这可能会影响其他用户,具体取决于他们服务器的设置方式.如果这是在您自己的计算机上,则需要在没有该开关的情况下重建PHP,或者从PECL手动安装Phar(不知道它在5.3中是否仍然有效,但我不知道为什么不行).

If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).

这篇关于找不到类"PharData"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆