Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法创建PHAR存档_Php_Phar - Fatal编程技术网

Php 无法创建PHAR存档

Php 无法创建PHAR存档,php,phar,Php,Phar,我是个PHP新手 我已经试着对我的计划作了一番推敲 我的项目包括5个目录和每个目录中的多个类 我遵循了这个教程 我做了以下几件事: 我在main index.php中添加了以下几行: $sLibraryPath = 'lib/myPhar.phar'; // we will build library in case if it not exist if (! file_exists($sLibraryPath)) { ini_set("phar.readonly", 0); // C

我是个PHP新手

我已经试着对我的计划作了一番推敲

我的项目包括5个目录和每个目录中的多个类

我遵循了这个教程

我做了以下几件事:

我在main index.php中添加了以下几行:

$sLibraryPath = 'lib/myPhar.phar';

// we will build library in case if it not exist
if (! file_exists($sLibraryPath)) {
   ini_set("phar.readonly", 0); // Could be done in php.ini

   $oPhar = new Phar($sLibraryPath); // creating new Phar
   $oPhar->setDefaultStub('index.php', 'classes/index.php'); // pointing main file which require all classes
   $oPhar->buildFromDirectory('classes/'); // creating our library using whole directory

   $oPhar->compress(Phar::GZ); // plus - compressing it into gzip
}

我创建了一个名为classes的新文件夹,并在其中创建了index.php文件,在那里我包含了所有的项目类

我已经创建了chmod777以下目录:lib、HelloWorld、HelloWorld/index.php、

并更改了phar.readonly。(phar.readonly=0)

但我还是得到了这样的信息:

Fatal error: Uncaught exception 'PharException' with message 'unable to create temporary file' in /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php:10 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php(10): Phar->setDefaultStub('index.php', 'classes/index.p...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php on line 10
我还没有找到任何有用的信息如何处理它,我将非常感谢你的帮助


(如果有更好的方法来创建PHAR,那就好了)

我不确定这是否是重点,但请查看此链接
可能你在临时目录上也遇到了同样的问题吗?

我不确定这是否是重点,但请检查此链接
您可能在使用temp目录时遇到同样的问题?

使用PHP2Phar包从PHP文件创建Phar文件

链接:

用法:

$ php php2phar.phar --dir-source <path/to/dir> --index-file </path/to/index.php> --output-file <path/to/file.phar>  
$php php2phar.phar--dir source--index file--output file

使用PHP2Phar包从PHP文件创建Phar文件

链接:

用法:

$ php php2phar.phar --dir-source <path/to/dir> --index-file </path/to/index.php> --output-file <path/to/file.phar>  
$php php2phar.phar--dir source--index file--output file

是的,我看到了这一点,但我真的不知道如何处理他的答案:“是的,但这与可扩展磁盘是平行的。我已经创建了一个固定磁盘并将其挂载在/tmp上,现在编译成功了。@user2515512他正在运行mac os,所以Parallels有一些神奇之处:)你可以使用本文来检查PHP如何与tmp目录交互是的,我看到了这一点,但我真的不知道如何处理他的答案:“是的,但这与可扩展磁盘是平行的。我已经创建了一个固定磁盘并将其挂载在/tmp上,现在编译成功了。@user2515512他正在运行mac os,因此Parallels有一些神奇之处:)您可以使用本文来检查PHP如何与tmp目录交互。请在回答中透露这是您自己的项目。我可以请你阅读我删除了这个答案的其他副本。请在你的答案中透露这是你自己的项目。我可以请你阅读我删除了这个答案的其他副本。