An open API service indexing awesome lists of open source software.

https://github.com/mevdschee/compress.php

Lossless compression of PHP files
https://github.com/mevdschee/compress.php

Last synced: 8 months ago
JSON representation

Lossless compression of PHP files

Awesome Lists containing this project

README

          

# compress.php

Lossless compression of PHP files using 'halt_compiler' and 'gzdeflate'.

### Usage

Copy the code below to a file called 'compress.php' and then on the command line run it like this:

$ php compress.php api.php
compressed 'api.php' from 259 to 41 kbyte (16%)

As you can see compressing 'api.php' reduces it's file size to 16% of the original, which is typical for PHP code and the 'deflate' algorithm. And now run it again:

$ php compress.php api.php
uncompressed 'api.php' from 41 to 259 kbyte (624%)

The script will detect operating on an already compressed file (it looks for the 'halt_compiler' statement) and will automatically switch to uncompression mode. Since the compression is lossless you will end up with the exact same file you started with.