Page 1 of 1
Shrink PHP code
Posted: Wed Aug 19, 2009 6:29 pm
by danielrs1
Yes, this is weird. I need to shrink some PHP code. Does anyone know a script that does this?
Re: Shrink PHP code
Posted: Wed Aug 19, 2009 9:20 pm
by Ollie Saunders
A quick google produced
this. Use the verb
minify or noun
minification to search for other implementations if you wish.
Re: Shrink PHP code
Posted: Thu Aug 20, 2009 9:06 am
by danielrs1
thanks. I can find lot's of tool for js, css and html, but I couldn't find any for PHP.
Re: Shrink PHP code
Posted: Thu Aug 20, 2009 9:07 am
by Ollie Saunders
Why do you need this?
Re: Shrink PHP code
Posted: Thu Aug 20, 2009 5:01 pm
by danielrs1
I've made a PHP app for a contest that has a 100KB limit. My app is slight bigger, so I need to make it smaller
Re: Shrink PHP code
Posted: Thu Aug 20, 2009 5:08 pm
by jackpf
Try removing all the tabs and new lines. Comments too.
You could base64 encode it and eval it on execution. That should compress it a bit...
Re: Shrink PHP code
Posted: Thu Aug 20, 2009 6:03 pm
by Ollie Saunders
You could:
- Refactor; there's probably duplicated code you can remove. The shear number of refactors that are possible virtually guarantee this will be useful unless your code is already very well factored, which almost nobody's is.
- Remove some unnecessary features; at least one is present in nearly every project, sometimes there are many.
- Change to tab indentation if you were using spaces.
- As jackpf suggested, removing unnecessary comments it also good. A lot of people repeat the license in every file for instance.
Re: Shrink PHP code
Posted: Tue Sep 01, 2009 10:58 am
by danielrs1
I have already done what you suggested, but thanks anyway.
Re: Shrink PHP code
Posted: Tue Sep 01, 2009 1:07 pm
by John Cartwright
jackpf wrote:Try removing all the tabs and new lines. Comments too.
You could base64 encode it and eval it on execution. That should compress it a bit...
The Manual wrote:Base64-encoded data takes about 33% more space than the original data.
Re: Shrink PHP code
Posted: Wed Sep 02, 2009 10:29 am
by jackpf
Oh right. My bad.