Doc #58722 [Opn->Csd]: confusion about using .tar.phar and the compressed version and the stub

From: Date: Sat, 01 Feb 2014 10:07:49 +0000
Subject: Doc #58722 [Opn->Csd]: confusion about using .tar.phar and the compressed version and the stub
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10918@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=58722&edit=1 ID: 58722 Updated by: krakjoe@php.net Reported by: carsten dot harnisch at intradesys dot com Summary: confusion about using .tar.phar and the compressed version and the stub -Status: Open +Status: Closed Type: Documentation Problem -Package: phar +Package: *General Issues Operating System: linux PHP Version: 5.3.0RC3 -Assigned To: +Assigned To: krakjoe Block user comment: N Private report: N New Comment: This bug is reported for an unsupported version of PHP and is not connected to security. It is therefore being closed. If the bug is still present in a stable, supported version of PHP, please do open a new bug report. Thanks for taking the time to help make PHP better :) Previous Comments: ------------------------------------------------------------------------ [2009-06-15 10:33:54] carsten dot harnisch at intradesys dot com 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. ------------------------------------------------------------------------ [2009-06-15 09:33:17] greg at chiaraquartet dot net Hi Carsten, To have control over the extension, use Phar::convertToExecutable() or Phar::convertToData(). Feel free to add a note to the compress() documentation. Greg ------------------------------------------------------------------------ [2009-06-15 09:22:32] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=58722&edit=1

« previous php.doc.bugs (#10918) next »