Phar behaviour

From: Date: Sat, 09 Feb 2008 21:40:17 +0000
Subject: Phar behaviour
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5108@lists.php.net to get a copy of this message
Hi interested parties and Greg, I was testing earlier and came up with a bunch of anomalies around Phar archive naming. What should be the expected behaviour for running "php <file>" in these situations? 1. file.zip or file.tar when Phar is enabled 2. file.tar.gz or file.tar.bz2 when Phar is enabled 3. file.phar.zip (or tar) when Phar is enabled 4. file.phar.zip (or tar) when Phar is not enabled 5. file.phar.gz when Phar is enabled/disabled 6. file.phar.bz2 when Phar is enabled/disabled IMHO Phar should attempt to insert a mini-stub into file.zip or file.tar, the same way it currently does if a third-party ZIP archive is renamed to file.phar.zip. Also IMHO, a file named file.phar.zip or file.phar.tar should work exactly like a standard .phar AND exactly like a standard .zip or .tar, if Phar is enabled. I'm not quite sure what should happen there if Phar isn't installed. This brings me to the next question: What exactly is file.phar.zip? Is it a .phar that was created as a PHAR/ZIP archive, or a .phar that was converted to a ZIP archive, and is there supposed to be any difference? The difference I'm seeing here - assuming the default stub was used - is that if you run a .phar that was converted to a ZIP archive without Phar installed you get something like: C:\sandbox\php5\Release_TS>php myphar.phar.zip
DÐÂ☺        Hello World          ↕ index.phpnu♫ x
DÐÂ☺        ERROR: manifest length read was "320" should be "1713645682"
whereas the same .phar created as a PHAR/ZIP will run under PHP regardless of whether Phar is enabled or not. (Caveat A: I don't know whether either behaviour should be considered buggy. Caveat B: I'm seeing a new-since-last-week bug in phar.zip creation which may be affecting my results.) Last point: Since any renaming at present is wholly left to the user, there's no way to know what a file is by just looking at it. I think the conversion methods should actually change the name of the file appropriately so that third-party tools (and users!) have a fighting chance. Comments? - Steph

« previous php.pecl.dev (#5108) next »