[PHP/Linux] RAR files, Linux and PHP

I am working on an application to Rar and UnRar files, the latter of which is possible through native PHP functions, but the Raring (compressing/arching/packing/creating) isn’t. I know that the same program that allows for UnRaring is available, but for some reason is not implemented already in PHP. Unfortunately, I lack the skill and the know-how to integrate a program with a PHP script, much less in Linux, an OS I have little experience in.

Any help would be very appreciated.

Rarlabs: http://rarlabs.com/download.htm
PHP Classes compression class (Windows only): http://www.phpclasses.org/browse/package/3556.html
PHP native RAR functions: http://www.php.net/rar

If you know how to do it on command line, you can utilize the shell_exec or exec functions to execute it from within the webserver.

I have made use of this command on several occasions with great success. It may not be the most efficient way to perform a task, it does work.

When using exec() functions, be sure to realize what kind of security issue this could pose! Any security hole could allow a random user to execute code on your Linux machine and you don’t want someone running ‘rm -rf’ on it ‘just to see if it works’.


Keep security utmost in your mind when running commands this way. It should be limited to exactly what is needed and even that should be validated.

Unfortunately, I always assume security, but forget to convey it. Thank You Zyppora for keeping me in check.

Sponsor our Newsletter | Privacy Policy | Terms of Service