There are builtin command utilities to tar/zip the files in lunux. What you need to do is to create a shell script which calls these utilities based on your requirements. Then call this shell script from PHP. Alternatively you can copy all relevant files to a folder and tar this folder using shell script..
Hope this helps..
Tom