PHPackages                             iautomation/filesystem-helper - 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. iautomation/filesystem-helper

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

iautomation/filesystem-helper
=============================

1.0.0(10y ago)55.6k12MITPHP

Since Feb 17Pushed 10y ago2 watchersCompare

[ Source](https://github.com/iautomation/PHP-Filesystem-Helper)[ Packagist](https://packagist.org/packages/iautomation/filesystem-helper)[ RSS](/packages/iautomation-filesystem-helper/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (2)

PHP-Filesystem-Helper
=====================

[](#php-filesystem-helper)

A helper class for filesystem operations

This class uses PHP Iterators in order to dynamically and stably provide filesystem operation access.

Introduction
------------

[](#introduction)

I tried to make this as fluid and dynamic as possible. Strangely, I couldn't seem to find any presently existing dynamic classes for file io operations, so I spent a couple hours coding this up. Please DO report possible errors.

I think the most important note is that Iterators do not take up massive amounts of memory like arrays do provided with glob and other methods. This class uses Iterators. Thus, we have speed + scalability.

Some might wonder why I did not implement glob methods. Two very good reasons led me to avoid glob:

1. Glob returns all results in an array, and has a relatively small limit(10,000 results or so).
2. Regex covers what glob provides, + more

That's all. Enjoy.

Overview
--------

[](#overview)

The following methods are provided:

- `public static function create($folder, $mode=0777, $recursive=true)`
- `public static function read($file)`
- `public static function write($file, $contents, $flag='w+')`
- `public static function searchR($folder, $pattern=null, $depth=-1, $flags=RecursiveIteratorIterator::SELF_FIRST)`
- `public static function search($folder, $pattern=null)`
- `public static function deleteR($folder, $pattern=null, $depth=-1)`
- `public static function delete($folder_or_file, $pattern=null)`

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

[](#installation)

The class can be used standalone, however it's recommended to install via Composer:

`composer require iautomation/filesystem-helper`

Usage
-----

[](#usage)

If using Composer, just do something like:

```
use \FilesystemHelper\FilesystemHelper;

include 'path/to/vendor/autoload.php';

FilesystemHelper::deleteR('test', null); // DELETE TEST AND ALL CONTENTS!!

```

Otherwise, simply include the class:

```
use \FilesystemHelper\FilesystemHelper;

include 'path/to/FilesystemHelper.php';

FilesystemHelper::deleteR('test', null); // DELETE TEST AND ALL CONTENTS!!

```

Examples
--------

[](#examples)

```
// create test folder
FilesystemHelper::create('test');

// write to test/test.php
FilesystemHelper::write('test/test.php', 'test123');

// get file contents
echo FilesystemHelper::read('test/a.php');

// get all direct folders and files under test
foreach(FilesystemHelper::search('test') as $file){
	echo $file."\n";
}

// get all folders and files under test recursively
foreach(FilesystemHelper::searchR('test') as $file){
	echo $file."\n";
}

// get all direct files under test with the php extension using regex
foreach(FilesystemHelper::search('test', '/.*.php/') as $file){
	echo $file."\n";
}

// get all recursive files under test with the php extension using regex
foreach(FilesystemHelper::searchR('test', '/.*.php/') as $file){
	echo $file."\n";
}

// get all directories under test
foreach(FilesystemHelper::searchR('test') as $file){
	if($file->isDir())
		echo $file."\n";
}

// get all files under test
foreach(FilesystemHelper::searchR('test') as $file){
	if($file->isFile())
		echo $file."\n";
}

// get all folders and files under test listed "backwards". This is particularly useful when deleting
$iter = FilesystemHelper::searchR('test', null, -1, RecursiveIteratorIterator::CHILD_FIRST);
foreach($iter as $file){
	echo $file."\n";
}

/**
DELETE FUNCTIONS ARE NOT FORGIVING. USE WITH CAUTION
*/

// delete all folders and files under test recursively
FilesystemHelper::deleteR('test', null);

// delete all direct folders and files under test
FilesystemHelper::delete('test', null);

// delete all recursive files under test with the php extension using regex
FilesystemHelper::deleteR('test', '/.*.php/', 1);

// delete the test/test.php file
FilesystemHelper::delete('test/test.php');

```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

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

Unknown

Total

1

Last Release

3789d ago

### Community

Maintainers

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

---

Top Contributors

[![paamayim](https://avatars.githubusercontent.com/u/5298927?v=4)](https://github.com/paamayim "paamayim (8 commits)")

---

Tags

phpfilesystemfilefoldercreateremoverecursion

### Embed Badge

![Health badge](/badges/iautomation-filesystem-helper/health.svg)

```
[![Health](https://phpackages.com/badges/iautomation-filesystem-helper/health.svg)](https://phpackages.com/packages/iautomation-filesystem-helper)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k679.9M2.5k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[tomatophp/filament-browser

File &amp; Folders &amp; Media Browser With Code Editor

408.8k2](/packages/tomatophp-filament-browser)

PHPackages © 2026

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