From 963abb718ffe0c793aef7d2a70e8ee4911587562 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 2 Feb 2020 16:27:38 +0000 Subject: [PATCH] build/server-phar: compress using gzip (except stub) this produces a 75% reduction in phar size, at the expense of a slight degradation of autoloading speed and needing a writable tmpdir. --- build/server-phar.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/build/server-phar.php b/build/server-phar.php index 394e0f62c..f173b969d 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -104,14 +104,9 @@ function buildPhar(string $pharPath, string $basePath, array $includedPaths, arr yield "Added $count files"; if($compression !== null){ - yield "Checking for compressible files..."; - foreach($phar as $file => $finfo){ - /** @var \PharFileInfo $finfo */ - if($finfo->getSize() > (1024 * 512)){ - yield "Compressing " . $finfo->getFilename(); - $finfo->compress($compression); - } - } + yield "Compressing files..."; + $phar->compressFiles($compression); + yield "Finished compression"; } $phar->stopBuffering(); @@ -137,7 +132,23 @@ function main() : void{ [ 'git' => $gitHash ], - '