The problem of packaging a phar file is too large.

Source: Internet
Author: User
Inspired by an open-source tool, we used stream packaging and token_get_all to remove the blank php file. The package is only KB. Thank you for your attention. I added a simple file and a symfony process package to package MB, and composer...

Inspired by an open-source tool, we used stream packaging and token_get_all to remove the blank php file. The package is only KB. Thank you for your attention.

I added a simple file and a symfony process package, which had a huge size of 1.6 MB. the composer had packed so many files that it was only MB, so I was puzzled. Enclose the packaging code:


  getMessage(), PHP_EOL;} catch (BadMethodCallException $e) {    echo $e->getMessage(), PHP_EOL;}e('building...');$phar->buildFromDirectory(__DIR__);e('remove unused files...');array_walk($ignoreFiles, function ($file) use ($phar) {    $phar->delete($file);});e('set stub...');$phar->setStub($phar->createDefaultStub('deploy.php', 'deploy.php'));e('compress...');$phar->compressFiles(Phar::BZ2);e('build done.');function e($string){    echo $string, PHP_EOL;}

Reply content:

Inspired by an open-source tool, we used stream packaging and token_get_all to remove the blank php file. The package is only KB. Thank you for your attention.

I added a simple file and a symfony process package, which had a huge size of 1.6 MB. the composer had packed so many files that it was only MB, so I was puzzled. Enclose the packaging code:


  getMessage(), PHP_EOL;} catch (BadMethodCallException $e) {    echo $e->getMessage(), PHP_EOL;}e('building...');$phar->buildFromDirectory(__DIR__);e('remove unused files...');array_walk($ignoreFiles, function ($file) use ($phar) {    $phar->delete($file);});e('set stub...');$phar->setStub($phar->createDefaultStub('deploy.php', 'deploy.php'));e('compress...');$phar->compressFiles(Phar::BZ2);e('build done.');function e($string){    echo $string, PHP_EOL;}

I think you can convert the format to zip, and then view the archive content through the compression software, so that you can intuitively see the size of each component in the archive;

$phar->convertToExecutable(Phar::ZIP);

Hope to help you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.