using phar and compression
| From: | Hajo Locke | Date: | Wed, 08 Aug 2012 08:03:01 +0000 |
| Subject: | using phar and compression | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-318645@lists.php.net to get a copy of this message | ||
Hello,
i do some tests with phar. I have following script which is just adding some file and index.php is echoing "hello";
<?php
$phar = new Phar('project.phar', 0, 'project.phar');
$phar->buildFromDirectory(dirname(__FILE__) . '/web');
$phar->setStub($phar->createDefaultStub('index.php'));
$compressed = $phar->convertToExecutable(Phar::PHAR,Phar::GZ, '.phar.tgz');
?>
This is working and i can call resulting by: "php project.phar"
Now i change last line to:
$compressed = $phar->convertToExecutable(Phar::TAR,Phar::GZ, '.phar.tgz');
Now the final phar archive should be compressed with tar. Creating the archive works without errors, but i cant run it.
Viewing file project.phar.tgz shows only binary-content, no php-header. Running "php project.phar.tgz" shows no output.
As i understood i can run any phar archive, regardless of used compressionmethod. Is this right? Am i using phar the correct way?
Thanks,
Hajo