What are the benefits of the different PHP compression libraries?

不羁岁月 提交于 2019-12-11 01:36:00

问题


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.

I've specifically been reading about bcompiler and PHAR libraries. 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?

======================= 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.
  • Python has this really cool pre-compiling policy, I wonder if PHP has something like that? 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

回答1:


Phar just packages a selection of php scripts into one file - the app contained can then be run without having to unpackage it first. The point of phar is not to precompile (for speed) or compress (for space) the app, just to make it more distributable.

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.




回答2:


Php also has "precompiler" support, but that's called "bytecode cache". 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.

Notable examples are APC and eAccelerator.



来源:https://stackoverflow.com/questions/2457105/what-are-the-benefits-of-the-different-php-compression-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!