An open API service indexing awesome lists of open source software.

https://github.com/selective-php/rar

RAR file reader for PHP
https://github.com/selective-php/rar

php rar rar-archives rar-files rar-format

Last synced: about 1 year ago
JSON representation

RAR file reader for PHP

Awesome Lists containing this project

README

          

# selective/rar

RAR file reader for PHP.

[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/rar.svg)](https://packagist.org/packages/selective/rar)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://github.com/selective-php/rar/workflows/build/badge.svg)](https://github.com/selective-php/rar/actions)
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/rar.svg)](https://scrutinizer-ci.com/g/selective-php/rar/code-structure)
[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/rar.svg)](https://scrutinizer-ci.com/g/selective-php/rar/?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/selective/rar.svg)](https://packagist.org/packages/selective/rar/stats)

## 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](https://www.php.net/manual/en/book.rar.php) is **NOT** required

## Installation

```
composer require selective/rar
```

## Usage

### Open RAR file

```php
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

```php
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](LICENSE) for more information.