[英]Modify PHAR file
I need to modify a PHAR file. 我需要修改一个PHAR文件。 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". 提取phar,修改它然后“将其放回phar文件”。 How do I do that?
我怎么做?
or set phar.require_hash = false
in my php.ini to disable the signature checking. 或者在我的php.ini中设置
phar.require_hash = false
来禁用签名检查。 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: 问题是在Symfony网站上,install命令如下所示:
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
. 并将文件
symfony.phar
移动到您想要创建项目的位置,或者将文件symfony
重命名为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). 如果文件名为
symfony
,则会出现此错误“sha1签名无法验证损坏的签名”,因为更改文件名也会使sha1无效(这就是散列的工作原理)。
You cannot simply change the phar contents in an editor, just like you can't do that in a .zip
or .tbz2
file. 你不能简单地在编辑器中更改phar内容,就像你不能在
.zip
或.tbz2
文件中那样做。
The only solution that will work is extracting the phar, modifying the extracted files and then re-packaging the phar file. 唯一可行的解决方案是提取phar,修改提取的文件,然后重新打包phar文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.