質問

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

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

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

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

And this is the code which fail :

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

This code is working fine on my own computer.

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

Thanks for your help!


UPDATE :

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 autoloader is doing the include_once(PharData.php).

役に立ちましたか?

解決

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();
?>

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.

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).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top