I am currently experimenting with an extension mechanism for my structure. Each module consists of at least one PHP file (defining one class) and an XSL stylesheet, but several other files could potentially be involved, so I immediately thought about using Phars.
Everything plays well together, but I noticed that if I did not use createDefaultStub() and instead created Phar, as in the following fragment, then the result will be a quarter of the size - and smaller than the compressed version.
$phar = new Phar('Example.phar', 0, 'Example.phar'); $phar->buildFromDirectory(__DIR__ . '/src'); $phar->setStub('<?php __HALT_COMPILER();'); $phar->setSignatureAlgorithm(Phar::SHA256); $phar->compress(Phar::GZ);
Example file size:
8799 14 Dec 09:37 ExampleCog.phar (using createDefaultStub()) 2143 14 Dec 10:08 ExampleCog.phar (using __HALT_COMPILER()) 3373 14 Dec 10:08 ExampleCog.phar.gz (consistent with either method)
Phar will simply be used to store the files associated with the module in the kit and will be included in the structure. Working offline will not make any sense in this context. I think my question is what I missed - if anything - using a minimal stub code? And why is the compressed version always the same size?
source share