简体   繁体   English

不同的PHP压缩库有什么好处?

[英]What are the benefits of the different PHP compression libraries?

I've been looking into ways to compress PHP libraries, and I've found several libraries which might be useful, but I really don't know much about them. 我一直在研究压缩PHP库的方法,我发现了几个可能有用的库,但我真的不太了解它们。

I've specifically been reading about bcompiler and PHAR libraries. 我一直在阅读有关bcompiler和PHAR库的内容。 Is there any performance benefit in either of these? 这些中的任何一个都有任何性能优势吗? Are there any "gotchas" I need to watch out for? 有什么“陷阱”我需要注意吗? What are the relative benefits? 有什么相对的好处? Do either of them add to/detract from performance? 他们中的任何一个是否会增加/减少性能?

I'm also interested in learning of other libs which might be out there which are not obvious in the documentation? 我也有兴趣学习其他可能在文档中不明显的库?

As an aside, does anyone happen to know whether these work more like zip files which just happen to have the code in there, or if they operate more like Python's pre-compiling which actually runs a pseudo-compiler? 顺便说一句,有没有人碰巧知道这些工作是否更像是恰好在那里有代码的zip文件,或者它们是否更像Python的预编译实际运行伪编译器?

======================= EDIT ======================= =======================编辑=======================

I've been asked, "What are you trying to accomplish?" 我被问到,“你想要完成什么?” Well, I suppose the answer is that this is all hypothetical. 好吧,我想答案是这都是假设的。 It is a combination of these: 它是这些的组合:

  • What if my pet project becomes the most popular web project on earth and I want to distribute it quickly and easily? 如果我的宠物项目成为世界上最受欢迎的网络项目并且我想快速轻松地分发它会怎么样? (hay, a man can dream, right?) It also seems if using PHAR can be done easily, it would be the best way to create a subversion snapshot. (干草,男人可以做梦吧?)似乎如果能够轻松地使用PHAR,这将是创建颠覆快照的最佳方式。
  • Python has this really cool pre-compiling policy, I wonder if PHP has something like that? Python有这个非常酷的预编译策略,我想知道PHP是否有这样的东西? These libraries seem to do something similar. 这些库似乎做了类似的事情。 Will they do that? 他们会这样做吗?
  • Hey, these libraries seem pretty neat, but I'd like clarification on the differences as they seem to do the same thing 嘿,这些库看起来很整洁,但我想澄清差异,因为它们似乎做同样的事情

Phar just packages a selection of php scripts into one file - the app contained can then be run without having to unpackage it first. Phar只是将一系列php脚本打包成一个文件 - 然后可以运行包含的应用程序,而无需先将其解包。 The point of phar is not to precompile (for speed) or compress (for space) the app, just to make it more distributable. phar的要点不是为应用程序预编译(速度)或压缩(用于空间),只是为了使其更易于分发。

What are you trying to achieve? 你想要实现什么目标? Script file size is never really an issue, as the script is not coming over the wire each time its' called. 脚本文件大小永远不会成为问题,因为每次调用脚本时脚本都不会通过网络传输。 Speed can be resolved by caching using something like Zend or precompiling using something like Hip Hop , which runs Facebook. 速度可以通过使用像Zend这样的缓存来解决,或者使用像运行Facebook的Hip Hop这样的预编译来解决。

Php also has "precompiler" support, but that's called "bytecode cache". Php也有“预编译器”支持,但这称为“字节码缓存”。 Using on removes the need for php to parse and compile the .php files each time, and you really rellay should be using one everywhere you run PHP applications. 使用on消除了每次解析和编译.php文件的需要,并且您真正重新启动应该在运行PHP应用程序的任何地方使用它。

Notable examples are APC and eAccelerator . 值得注意的例子是APCeAccelerator

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

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