Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

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).

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.

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

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