我们在我们的服务器上使用Ubuntu + nginx + PHP5-FPM组合,使用PHP版本为5.5。我们正在尝试运行index.php,其中包含一堆Phar文件。类似:

<?php
include "a.phar";
include "b.phar";
//...
?>
.

当此脚本从命令行PHP运行时,它可以正常工作。当这是从PHP开发服务器(PHP -S)或NGINX运行时,我们收到以下错误:

2013/11/18 17:56:06 [error] 14384#0: *597 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Cannot redeclare class Extract_Phar in b.phar on line 103
.

我没有一个名为Extract_phar的类 - 所以我假设我的构建过程正在向上添加它。我用过的phing来构建相同的,以防万一。phing目标是:

<target name="phar" depends="prepare">
  <pharpackage destfile="./build/phar/LogUtils.phar" 
  basedir="./build/intophar"
  compression="bzip2">
  <fileset dir="./build/intophar/">
    <include name="*.*" />
    <include name="**/**" />
  </fileset>
  <metadata>
    <element name="version" value="1.0" />
    <element name="authors">
       <element name="Shreeni">
         <element name="e-mail" value="test@test.com" />
       </element>
    </element>
  </metadata>
  </pharpackage>
</target>
.

和我的IntoPar文件夹中的index.php是:

include("api/LogUtils.inc.php");
// Other relative include statements
.

我已经根据其他答案与APC标志一起播放,并设置了以下内容:

apc.include_once_override = 0 
apc.canonicalize = 0 
apc.stat = 0
apc.enabled=0 
apc.enabled_cli=0
apc.cache_by_default = 0
.

没有任何帮助,我们无法运行我们的代码。有什么建议么?

有帮助吗?

解决方案

由于各种Phar文件中的存根冲突,可能会发生问题。尝试:

<?php
include "phar://a.phar/index.php"; // Assuming that the stub is index.php
include "phar://b.phar/index.php"; // Assuming that the stub is index.php
//...
?>
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top