Skip to content

selective-php/rar

Repository files navigation

selective/rar

RAR file reader for PHP.

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Features

  • Read RAR file information
  • RAR 5 archive format
  • RAR 4 archive format
  • No dependencies
  • Very fast

Note: This package does not support extracting / unpacking rar archives.

Requirements

  • PHP 8.1+

The PECL RAR package is NOT required

Installation

composer require selective/rar

Usage

Open RAR file

use Selective\Rar\RarFileReader;
use SplFileObject;

$rarFileReader = new RarFileReader();
$rarArchive = $rarFileReader->openFile(new SplFileObject('test.rar'));

foreach ($rarArchive->getEntries() as $entry) {
    echo $entry->getName() . "\n";
}

Open in-memory RAR file

use Selective\Rar\RarFileReader;
use SplTempFileObject;

$file = new SplTempFileObject();
$file->fwrite('my binary rar content');

$rarFileReader = new RarFileReader();
$rarArchive = $rarFileReader->openFile($file);

foreach ($rarArchive->getEntries() as $entry) {
    echo $entry->getName() . "\n";
}

License

The MIT License (MIT). Please see License File for more information.