简体   繁体   中英

Modify PHAR file

I need to modify a PHAR file. Whenever I make changes to the file and then execute it I get the following error message:

Fatal error: Uncaught exception 'PharException' with message SHA1 signature could not be verified: broken signature'

By doing some research I found out that I can either

  • extract the phar, modify it and then "put it back into a phar file". How do I do that?

  • or set phar.require_hash = false in my php.ini to disable the signature checking. This did not solve the problem unfortunately

I only have to do a few simple modifactions to the file and I'm the only one who is going to use it so I would prefer a quick and easy solution to the problem

The problem is that on the Symfony website the install command looks like this:

c:\> php -r "readfile('http://symfony.com/installer');" > symfony

The correct command is

c:\> php -r "readfile('http://symfony.com/installer');" > symfony.phar

And move the file symfony.phar wherever you want to create your projects OR, just rename the file symfony to symfony.phar . If the file is named just symfony you will get this error "sha1 signature could not be verified broken signature" because changing the name of the file will also invalidate the sha1 (that's how hashing works).

You cannot simply change the phar contents in an editor, just like you can't do that in a .zip or .tbz2 file.

The only solution that will work is extracting the phar, modifying the extracted files and then re-packaging the phar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM