Answering your question firstly you need to ask yourself why do you need it?
The purpose of compression data is to send/recieve it faster. It make sense for JavaScript, Images, CSS, HTML etc. and for that reason there are some tools.
For example: Best JavaScript compressor for JavaScript.
Apache has also a module for compression it is called Mod deflate You can use it for example via .htaccess file
To compress JS file
AddOutputFilterByType DEFLATE application/javascript
To compress html
AddOutputFilterByType DEFLATE text/html
More you can read on http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
Anyway, this is to reduce the time of page loading.
Php Scripts works on server side, the code is not shown in browser but the **result* of code is. That is why unless you care for the space on your server and you want to save 10 kB it has no matter! If you reduce php code it won't reduce the time of loading page. Instead you should make code better or use cache.
I hope you understand the difference between client side of scripts(JS) and server side(PHP).
you wrote in comment that your purpose is to " increase the performance" you will not achieve it by minifing code you will achieve it by making code better, profiling application, reduce unnecessary code, caching result of functions that take time and so on.