tags:

views:

1212

answers:

5

Where can I find a free, lightweight YUI-like compressor for PHP?

I am sure it will decrease the file size but will compressing PHP code boost its performance?

Is this the same thing as an obfuscator?

+5  A: 

There is a product called PHP Encoder by ionCube (http://www.ioncube.com/sa_encoder.php) which is enterprise grade compression and obfuscater.

PHP Encoder is a PHP extension to create and run compiled bytecodes for accelerated runtime performance and maximum security.

It will shrink the file size, and speed up runtime because the code is already partially compiled

deepwell
+7  A: 

Compressing JavaScript has benefits because the script has to be sent over the Net to the client before it can be interpreted -- the smaller the file size, the faster it reaches the end user. PHP is interpreted directly on the server, so compressing the code won't affect how fast it runs.

If it's speed gains you want, you should look into a PHP accelerator that will cache the compiled PHP bytecode of your app.

scronide
That's not entirely true. With less whitespace to process the file can be parsed and tokenized faster. However, this is likely to be negligible
foxxtrot
talk about splitting hairs
Here Be Wolves
+1  A: 

NuSphere has also released Nu-Coder for both securing code and accelerating it.

Darryl Hein
+2  A: 

It's a rather pointless exercise -- with JS you want compression 'cos you download it but PHP scripts are not downloaded. You need your code pretty and commented and all to participate in an open source community anyways. If you don't then you are a dinosaur right on the path to die out.

I agree with you. But sometimes there are legitimate reasons to do this.
benlumley
+3  A: 

I'd also recommend using a PHP bytecode cache (we're on APC).

But just for completeness: PHP has a function php_strip_whitespace() which removes comments and unnecessary whitespace (or run "php -w" from the command line).