php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
22 - 21 = ?
Subscribe to this entry?

 
 [2009-10-01 20:57 UTC] admin at sulehosting dot co dot za
Description:
------------
I am trying to create a phar file, following examples from the php.net
http://us.php.net/manual/en/phar.using.object.php



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

and 

<?php
$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

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-02 11:37 UTC] sjoerd@php.net
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] fa@php.net
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);

if($res):
    print 'it works';
else:
    print 'it failed';
endif;

2)uname -a
Linux pegasus 2.6.27.29-0.1-pae #1 SMP 2009-08-15 17:53:59 +0200 i686 i686 i386 GNU/Linux
 [2009-10-05 11:24 UTC] sjoerd@php.net
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] sjoerd@php.net
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->startBuffering();
    $phar['test.txt'] = 'phar is here';
    $phar->setStub($phar->createDefaultStub('index-cli.php', 'index.php'));
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC