clue / phar-composer

Simple phar creation for every PHP project managed via Composer
https://clue.engineering/2019/introducing-phar-composer
MIT License
855 stars 78 forks source link

appends when executed multiple times #100

Closed DanielRuf closed 2 years ago

DanielRuf commented 4 years ago

It seems when I run it locally multiple times it appends the same content to the same phar.

➜  Project git:(master) ✗ php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (5470.5 KiB)

    OK - Creating project.phar (10941.1 KiB) completed after 1s
➜  Project git:(master) ✗ php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (10941.1 KiB)

    OK - Creating project.phar (16411.7 KiB) completed after 1.1s
➜  Project git:(master) ✗ php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (16411.7 KiB)

    OK - Creating project.phar (21882.3 KiB) completed after 1.4s
DanielRuf commented 4 years ago

Overwriting existing file project.phar

So it is not overwritten? At least it also seems the binentry is not used only once.

clue commented 4 years ago

@DanielRuf Thanks for reporting!

I understand where you're coming from and agree that this looks strange to say the least, but this is indeed expected behavior at the moment:

When running phar-composer, it will bundle all files from the local directory, i.e. it will include your existing project.phar into your new project.phar which causes the archive to grow on each run.

At the moment, this can be prevented by running this in a temporary build directory like #91. We will also likely add an option to ignore certain files via #5. I'm open for more input :+1:

DanielRuf commented 4 years ago

Hi @clue,

thanks for the feedback. I really appreciate the time that you invest into this and the other projects. I switched to the maintained box fork as this brought many improvements and worked for my needs.

I will revisit #91 in the next weeks and try this approach. Thanks for the links. I was already aware of #5 but I was not aware of #91 =)