简体   繁体   English

php Phar的几个问题

[英]A few php Phar questions

A few questions but I'm sure the answers will be useful for many getting to grips with the relatively new phar. 有几个问题,但是我敢肯定,答案对于许多掌握相对较新的法尔很有用。

  1. Is it possible to delete or edit a file inside the phar script, from within the phar script, when it's actually running? 实际运行时,是否可以从phar脚本中删除或编辑phar脚本中的文件?

  2. I've noticed that I can change the name of my phar file from examplename.phar to examplename.php and run it in the url and it still works fine. 我注意到我可以将phar文件的名称从examplename.phar更改为examplename.php并在url中运行它,但仍然可以正常工作。 is that right? 那正确吗? is that OK to do? 可以吗? is that safe? 这样安全吗?

  3. Is it better practice to put all your files in the same directory and then phar it, or is it OK to keep all your folders and sub folders and phar it like that - or does it not matter? 是将所有文件放在同一目录中然后进行Phar的更好的做法,还是可以保留所有文件夹和子文件夹并按Phar的方式进行处理-还是没关系?

  4. can you obfuscate the phar file. 您可以混淆phar文件吗? or will that ruin it? 还是会毁了它? does all obfuscating have to be done before pharing? 阶段化之前是否必须进行所有混淆处理?

Hopefully a phar expert can answer these. 希望法尔专家可以回答这些问题。 thanks 谢谢

  1. The usual setting of PHP is to treat PHAR files as readonly. PHP的通常设置是将PHAR文件视为只读。 In fact, you have to change that setting to allow your local copy of PHP to create these files. 实际上,您必须更改该设置以允许您的PHP本地副本创建这些文件。 I doubt they can be changed, I wouldn't bet on it. 我怀疑它们是否可以更改,我不会打赌。

  2. The general structure of a PHAR is an initial PHP script part that sets things up, and then a call to __halt_compiler() followed by zipped bytes (after transferring control to a script part already inside the PHAR), so you can do whatever is possible with any PHP script without PHAR, including changing it's name. PHAR的一般结构是一个初始的PHP脚本部分,它进行了设置,然后是对__halt_compiler()的调用,其后是压缩字节(将控制权转移到PHAR中已经存在的脚本部分之后),因此您可以做任何可能的事情任何不带PHAR的PHP脚本,包括更改其名称。 Note that the bootstrap code of already existing PHAR files might not allow this because of hardcoded filenames, but this is not the general case. 请注意,由于硬编码的文件名,已经存在的PHAR文件的引导程序代码可能不允许这样做,但这不是一般情况。

  3. It does not really matter. 这真的无所谓。

  4. Obfuscation on the code level that leave the PHP code in runnable condition with pure PHP won't affect PHAR. 在代码级别进行混淆会使纯PHP处于可运行状态的PHP代码不会影响PHAR。 Anything that expects PHP to already contain special extensions will probably fail. 任何期望PHP已经包含特殊扩展名的操作都可能会失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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