首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法创建PHAR存档

无法创建PHAR存档
EN

Stack Overflow用户
提问于 2014-03-16 19:08:48
回答 2查看 2.1K关注 0票数 2

我是一个PHP新手。。

我试着让我的项目变得更好。

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

我遵循了这篇教程

Phar – PHP archiving practice

我做了以下几件事:

在我的主index.php中,我添加了以下几行:

代码语言:javascript
复制
$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文件,其中包含了我所有的项目类。

我已经修改了以下目录: lib,HelloWorld,HelloWorld/index.php,

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

我还是收到了这样的信息:

代码语言:javascript
复制
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,那就好了)

EN

回答 2

Stack Overflow用户

发布于 2014-03-16 19:59:08

我不确定这是否是重点,但检查这个链接Bug #63112 PharException when compiling可能你有同样的问题与临时目录?

票数 0
EN

Stack Overflow用户

发布于 2016-10-04 01:26:22

使用PHP2Phar包从PHP文件创建您的Phar文件。

链接:https://github.com/00F100/php2phar

用法:

代码语言:javascript
复制
$ php php2phar.phar --dir-source <path/to/dir> --index-file </path/to/index.php> --output-file <path/to/file.phar>  
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22436045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档