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?
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?
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
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.
NuSphere has also released Nu-Coder for both securing code and accelerating it.
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'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).