Php5-FPM error including multiple phar files

We use a combination of Ubuntu + nginx + php5-fpm on our servers with PHP version 5.5. We are trying to run index.php, which includes a bunch of phar files. Something like:

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

When this script is run from the PHP command line, it works fine. When this is done from the php Development server (php -S) or with nginx, we get the following error:

 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 

I don't have an Extract_Phar class, so I assume that my build process adds it somewhere along the way. I used phing to build the same, just in case that helps. The purpose of the finger:

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

And index.php in my intophar folder is something like:

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

I played with apc flags based on other answers and installed the following:

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

None of this helps, and we cannot run our code. Any suggestions?

+8
php nginx phar phing
source share
1 answer

The problem may be due to conflicting stubs in your various phar files. Try:

 <?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 //... ?> 
+5
source share

All Articles