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

发布于 2024-08-25 08:06:30 字数 600 浏览 17 评论 0原文

我一直在研究压缩 PHP 库的方法,并且发现了几个可能有用的库,但我真的对它们了解不多。

我专门阅读了有关 bcompiler 和 PHAR 库的内容。这两者有任何性能优势吗?有什么我需要注意的“陷阱”吗?相对的好处是什么?它们中的任何一个会增加/降低性能吗?

我也有兴趣了解其他库,这些库可能在文档中并不明显?

顺便说一句,有谁知道这些工作是否更像是恰好有代码的 zip 文件,或者它们的工作方式是否更像 Python 的预编译,实际上运行一个伪编译器?

======================= 编辑 =========================

我已经被问到:“你想实现什么目标?”好吧,我想答案是这都是假设的。它是这些的组合:

  • 如果我的宠物项目成为地球上最受欢迎的 Web 项目并且我想快速轻松地分发它怎么办? (嘿,人是有梦想的,对吧?)似乎如果使用 PHAR 可以轻松完成,那么这将是创建颠覆快照的最佳方式。
  • Python 有这个非常酷的预编译策略,我想知道 PHP 是否也有类似的东西?这些库似乎做了类似的事情。他们会这么做吗?
  • 嘿,这些库看起来很整洁,但我想澄清一下差异,因为它们似乎做同样的事情

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相权↑美人 2024-09-01 08:06:30

Phar 只是将精选的 php 脚本打包到一个文件中 - 然后可以运行所包含的应用程序,而无需先将其解包。 phar 的目的不是预编译(为了速度)或压缩(为了空间)应用程序,只是为了使其更具可分发性。

你想达到什么目的?脚本文件大小从来都不是真正的问题,因为每次调用脚本时都不会通过网络传输。速度可以通过使用 Zend 之类的缓存或使用 Hip Hop 之类的东西进行预编译来解决,运营 Facebook 的公司。

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.

若水微香 2024-09-01 08:06:30

Php 还具有“预编译器”支持,但这称为“字节码缓存”。
使用 on 消除了 php 每次解析和编译 .php 文件的需要,并且您确实应该在运行 PHP 应用程序的任何地方使用 on 。

值得注意的例子有 APC

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文