PHPackages                             rcsofttech85/file-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. rcsofttech85/file-handler

ArchivedLibrary[File &amp; Storage](/categories/file-storage)

rcsofttech85/file-handler
=========================

A simple library for abstracting various file operations and providing additional helper functions for file manipulation

1.5.5(2y ago)23303MITPHPPHP &gt;8.2

Since Sep 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/rcsofttech85/php-file-helper)[ Packagist](https://packagist.org/packages/rcsofttech85/file-handler)[ RSS](/packages/rcsofttech85-file-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (16)Used By (0)

PHP File Helper
===============

[](#php-file-helper)

[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)[![Codacy Badge](https://camo.githubusercontent.com/02b2e25a994f8a7d4d0856b684f02c0f179572d5af9045232f39fb8eab8ba29b/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6336343530613963306639393438386539336233343931316631616466623265)](https://app.codacy.com/gh/rcsofttech85/php-file-helper/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Codacy Badge](https://camo.githubusercontent.com/16e973f6cf36b63e83c949043f4df0ef503a2b47d323b01b87453500f2dbf3a3/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f6336343530613963306639393438386539336233343931316631616466623265)](https://app.codacy.com/gh/rcsofttech85/php-file-helper/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)

A simple PHP file helper for various file operations.

---

Table of Contents
-----------------

[](#table-of-contents)

- [About](#about)
- [Installation](#installation)
- [Usage](#usage)
    - [Search by Keyword](#search-by-keyword)
    - [Search by keyword and return array](#search-and-return-array)
    - [Write Multiple Files](#write-multiple-files-simultaneously)
    - [Converting File to Array](#converting-file-to-an-array)
    - [Find and Replace in CSV](#find-and-replace-in-csv-file)
    - [Converting File to JSON](#converting-file-to-json-format)
    - [Encrypt and Decrypt Files](#encrypt-and-decrypt-files)
    - [Stream and Save Content from URL](#stream-and-save-content-from-url-to-file)
    - [File Compression and Decompression](#file-compression-and-decompression)
    - [File Difference](#file-difference)
    - [File Integrity check](#file-integrity-check)
    - [View CSV in Terminal (table format)](#view-csv-in-terminal)
    - [View JSON in Terminal (table format)](#view-json-in-terminal)

About
-----

[](#about)

This PHP File Helper is designed to simplify various file-related operations. It offers a range of features to handle tasks such as searching for keywords in files, converting files to different formats, encrypting and decrypting files, and more. Whether you're working with CSV, JSON, or plain text files, this library can streamline your file management processes.

Installation
------------

[](#installation)

You can install this PHP File Helper library via Composer:

```
composer require rcsofttech85/file-handler
```

Usage
-----

[](#usage)

search by keyword
-----------------

[](#search-by-keyword)

```
     $temp = new TempFileHandler();
     $csv = new CsvFileHandler($temp);

     $findByKeyword = $csv->searchInCsvFile("movies.csv","Twilight","Film");

```

Search and return array
-----------------------

[](#search-and-return-array)

```
$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->searchInCsvFile("movies.csv","Twilight","Film",FileHandler::ARRAY_FORMAT);

// output

[
    [Film] => Twilight
    [Genre] => Romance
    [Lead Studio] => Summit
    [Audience score %] => 82
    [Profitability] => 10.18002703
    [Rotten Tomatoes %] => 49
    [Worldwide Gross] => $376.66
    [Year] => 2008

 ];

```

Write multiple files simultaneously
-----------------------------------

[](#write-multiple-files-simultaneously)

```
$fileHandler = new FileHandler();

$fileHandler->open('file.txt');

$fileHandler->open('php://stdout');

$fileHandler->write(data: "hello world");

$fileHandler->close();

```

Converting file to an array
---------------------------

[](#converting-file-to-an-array)

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->toArray("movies.csv");
// output
$data[0] = [
            'Film' => 'Zack and Miri Make a Porno',
            'Genre' => 'Romance',
            'Lead Studio' => 'The Weinstein Company',
            'Audience score %' => '70',
            'Profitability' => '1.747541667',
            'Rotten Tomatoes %' => '64',
            'Worldwide Gross' => '$41.94 ',
            'Year' => '2008'

        ];

```

Find and replace in csv file
----------------------------

[](#find-and-replace-in-csv-file)

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Twilight","Inception");

```

**Find and replace a specific keyword in a particular column of a CSV file**

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->findAndReplaceInCsv("movies.csv","Inception","Twilight",column: "Film");

```

Converting file to json format
------------------------------

[](#converting-file-to-json-format)

```

$temp = new TempFileHandler();
$csv = new CsvFileHandler($temp);

$findByKeyword = $csv->toJson("movies.csv");

//output
[{"Film":"Zack and Miri Make a Porno","Genre":"Romance","Lead Studio":"The Weinstein Company","Audience score %":"70","Profitability":"1.747541667","Rotten Tomatoes %":"64","Worldwide Gross":"$41.94 ","Year":"2008"},{"Film":"Youth in Revolt","Genre":"Comedy","Lead Studio":"The Weinstein Company","Audience score %":"52","Profitability":"1.09","Rotten Tomatoes %":"68","Worldwide Gross":"$19.62 ","Year":"2010"},{"Film":"Twilight","Genre":"Romance","Lead Studio":"Independent","Audience score %":"68","Profitability":"6.383363636","Rotten Tomatoes %":"26","Worldwide Gross":"$702.17 ","Year":"2011"}]

```

Encrypt and decrypt files
-------------------------

[](#encrypt-and-decrypt-files)

```

$secret = getenv('SECRET_KEY');

$fileEncryptor = new FileEncryptor('movie.csv', $secret);
$fileEncryptor->encryptFile();
$fileEncryptor->decryptFile();

```

Stream and save content from url to file
----------------------------------------

[](#stream-and-save-content-from-url-to-file)

```

 $url = "https://gist.github.com/rcsofttech85/629b37d483c4796db7bdcb3704067631#file-gistfile1-txt";
 $stream = new Stream($url, "outputFile.html");
 $stream->startStreaming();

```

File compression and decompression
----------------------------------

[](#file-compression-and-decompression)

```

        $testFile = 'movie.csv';
        $compressedZipFilename = 'compressed.zip';

        $this->fileHandler->compress($testFile, $compressedZipFilename);

        $compressedZipFilename = 'compressed.zip';
        $extractPath = 'extracted_contents';

        $this->fileHandler->decompress($compressedZipFilename, $extractPath);

```

File Difference
---------------

[](#file-difference)

```
vendor/bin/file-diff oldFile newFile

```

File Integrity Check
--------------------

[](#file-integrity-check)

```
$fileHasher = new FileHashChecker();

$fileHasher->hashFile();

$fileHasher->verifyHash($hashListFile);

```

View csv in terminal
--------------------

[](#view-csv-in-terminal)

```
vendor/bin/view-csv movies.csv --hide-column Film --limit 5

```

View json in terminal
---------------------

[](#view-json-in-terminal)

```
vendor/bin/view-json movies.json --hide-column Film --limit 5

```

Applying filters to a csv file
------------------------------

[](#applying-filters-to-a-csv-file)

[![Csv File](images/csv-view.jpeg)](images/csv-view.jpeg)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

15

Last Release

946d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/acf551384df4ef2ac01cd242fa6d3ffa5bbb9ce7a9d4c685923f27f9d38aa706?d=identicon)[rcsofttech85](/maintainers/rcsofttech85)

---

Top Contributors

[![rcsofttech85](https://avatars.githubusercontent.com/u/17738213?v=4)](https://github.com/rcsofttech85 "rcsofttech85 (88 commits)")

---

Tags

cli-utilitiesfile-array-conversionfile-compressionfile-difference-checkerfile-encryptionfile-integrity-checkfile-searchfile-streaming

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rcsofttech85-file-handler/health.svg)

```
[![Health](https://phpackages.com/badges/rcsofttech85-file-handler/health.svg)](https://phpackages.com/packages/rcsofttech85-file-handler)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
