|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-15 09:22 UTC] carsten dot harnisch at intradesys dot com
Description:
------------
just checking out the version 2.0.0RC2 I am bit confused
with the packing and compression functionality.
The basic use-case is to pickup the content of a directory
and package it as a compressed phar.
To package I did :
$libBaseFile = 'include_this.php';
$pharAlias = 'mylib.tar.phar';
$pathToOutput = 'lib/';
$pathToLib = 'src/';
$phar = new Phar($pathToOutput, 0, $pharAlias);
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($pathToLib)),
$pathToLib);
$phar->setStub(
'<?php '
// . 'echo "in stub<br>"; '
. 'Phar::mapPhar("' . $pharAlias . '"); '
. 'require_once "phar://" . __FILE__ . "/' . $libBaseFile
.'"; '
. '__HALT_COMPILER(); ?>'
);
$phar->compress(Phar::GZ);
The first weird thing I encountered is that if I called the
"$pharAlias" as "mylib.tar.phar" the resulting compressed
version will be "mylib.phar.tar.gz".
Not really sure if this is the attend way, so managling the
extension "tar.phar".
The next thing is that I would assume "including" the phar
later should run the stub. But in fact this is only the case
for the "uncompressed" version :
// this will work and "include" libBaseFile and defined in
the stub !
require_once 'phar://lib/mylib.tar.phar';
// this seems NOT running the stub ...
require_once 'phar://lib/mylib.phar.tar.gz';
// ... but this will work ...
require_once
'phar://lib/mylib.phar.tar.gz/include_this.php';
I am open to commit changes to the docs once the issue is
solved.
best wishes
Carsten
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 07:00:01 2026 UTC |
Greg, thanks for your help ... Just digging into the issue again. I found that the "problem" seems to be related to the way compress is working in relation to any "custom" stubs : This code here will produce the compressed phar (my.phar.gz) $phar = new Phar('my.phar', 0, 'my.phar'); $phar->setDefaultStub('other_than_index.php', 'other_than_index.php'); $phar->compress(Phar::GZ); so "compress" seems to ignore any custom-stubs; the resulting archive has always a "default-stub" with "index.php" inside. I assume that convertToExecutable works pretty much the same ?!? Not really sure if this is intended here, might be nicer to allow custom- stubs in a .gz also.