Question

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
Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top