Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify PHAR file

Tags:

php

phar

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

like image 848
marius2k12 Avatar asked Oct 03 '22 22:10

marius2k12


1 Answers

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).

like image 113
vectorialpx Avatar answered Oct 07 '22 17:10

vectorialpx