|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49741 I have a problem create a phar file on my system
Submitted: 2009-10-01 20:57 UTC Modified: 2009-10-06 11:21 UTC
From: admin at sulehosting dot co dot za Assigned:
Status: Not a bug Package: PHAR related
PHP Version: 5.3.0 OS: open suse 11.1
Private report: No CVE-ID: None
 [2009-10-01 20:57 UTC] admin at sulehosting dot co dot za
I am trying to create a phar file, following examples from the

Reproduce code:
$phar = new Phar("/tmp/first.phar",0,"first.phar");
$phar['hello.txt'] = 'hello world';


$phar = new Phar("/tmp/first.phar");
$phar['hello.txt'] = 'hello world';

Expected result:
I expect a phar file to be created in the tmp directory,

Actual result:
UnexpectedValueException: creating archive "/tmp/first.phar" disabled by INI setting in /srv/www/htdocs/PHAR/test_phar.php on line 2

Call Stack:
    0.0003     323772   1. {main}() /srv/www/htdocs/PHAR/test_phar.php:0
    0.0003     328724   2. Phar->__construct() /srv/www/htdocs/PHAR/test_phar.php:2

php --ri Phar


Phar: PHP Archive support => enabled
Phar EXT version => 2.0.0-dev
Phar API version => 1.1.1
CVS revision => $Revision: 1.370.2.62 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => enabled
OpenSSL support => enabled

Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.readonly => On => On
phar.require_hash => On => On
phar.cache_list => no value => no value


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-02 11:37 UTC]
Thank you for your bug report.

Please try setting phar.readonly to false. Does this solve the problem?
 [2009-10-02 11:59 UTC] admin at sulehosting dot co dot za
I tried setting phar.readonly to false, I no longer get the exception but there is still no phar created on the specified directory.
 [2009-10-03 18:45 UTC]
Could you please verify that writing to /tmp works at all (for example file_put_contents() in the same script) and also say if it's 32bit or 64bit
 [2009-10-05 08:45 UTC] admin at sulehosting dot co dot za
1)file_put_contents (works!)
$strFile = '/tmp/myFile.txt';
$strData = 'hello world';

$res = file_put_contents($strFile, $strData);

    print 'it works';
    print 'it failed';

2)uname -a
Linux pegasus #1 SMP 2009-08-15 17:53:59 +0200 i686 i686 i386 GNU/Linux
 [2009-10-05 11:24 UTC]
Could you please to run your example script again, with error reporting enabled and check whether it works? If it does not, please provide an strace, like this:

strace php -f foo.php 2> strace.txt

Please provide an URL to the strace here (you can use a pastebin). Thank you.
 [2009-10-05 21:17 UTC] admin at sulehosting dot co dot za
It works, the phar file gets created. Thanks a lot. I am trying to go through the changes to see what caused it to work.....
 [2009-10-06 11:21 UTC]
Setting to "Bogus" because it seemed to work after all.
 [2010-10-18 10:21 UTC] kazemipouya at gmail dot com
After one year of reporting this bug, I got the same problem. I followed 
all comments but for me, the phar is not there!!

    $phar = new Phar('./test.phar', 0, 'test.phar');
    $phar['test.txt'] = 'phar is here';
    $phar->setStub($phar->createDefaultStub('index-cli.php', 'index.php'));
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jul 25 04:01:23 2021 UTC