PHPackages                             niletphp/file-system - 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. niletphp/file-system

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

niletphp/file-system
====================

The NiletPHP file system component.

v1.0.0(9y ago)11693MITPHPPHP &gt;=7.0

Since Mar 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tsvetelintsonev/niletphp-file-system)[ Packagist](https://packagist.org/packages/niletphp/file-system)[ RSS](/packages/niletphp-file-system/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (3)

Object oriented design approach, that provides a convenient way for working with your file system.

### Requirements

[](#requirements)

`PHP >= 7.0`

### Install

[](#install)

Composer

```
{
    "require": {
        "niletphp/file-system": ">=v1.0"
    }
}
```

\###Handling errors By default the library registers custom error handler, which throws \\Error when PHP emits E\_WARNING or E\_ERROR. The \\Error is then being catched and `Nilet\Components\FileSystem\FileSystemException` is thrown

\###Examples

File system

```
use Nilet\Components\FileSystem\FileSystem;
use Nilet\Components\FileSystem\FileSystem\Directory;
use Nilet\Components\FileSystem\FileSystem\File;
use Nilet\Components\FileSystem\FileSystem\FileSystemException;

$fs = new FileSystem(); // with custom error handler
$fs = new FileSystem(false); // without custom error handler

// If you want to restore to previous custom event handler
$fs->restoreErrorHandler();

// Create directory example with try-catch
try {
    $fs->createDirectory(new Directory("foo/bar"), "nested/dir", 0750);
} catch(FileSystemException $exc) {
    // handle exception
}

// Delete all items of a given directory
$fs->cleanDirectory(new Directory("foo/bar"));

// Delete directory
$fs->deleteDirectory(new Directory("foo"));

// Create file
$file = $fs->createFile(new Directory("bar"), "foo.txt", 0640, "Foo bar");

// Delete file
$fs->deleteFile(new File("bar/foo.txt"));

/**
* Make copy of a given file.
* If the file already exists in the destination folder, it will be overwritten.
*/
$fs->copyFile(new File("foo/bar.txt"), new Directory("baz"));

/**
* Move uploaded file.
* If the file already exists in the destination folder, it will be overwritten.
*/
$fs->moveUploadedFile(new Directory("bar"), "tmp/tmpName.txt", "qux.txt")
```

Working with files

```
$file = new File("foo/bar.txt");

// Retrieve file name
$file->getName();

// Retrieve file name (with file extension)
$file->getBasename();

// Retrieve file extension e.g. txt, csv, php etc.
$file->getExtension();

//Retrieve file parent directory e.g. given a "foo/bar/baz.txt" will return  "foo/bar"
$file->getPath();

// Retrieve file real path e.g. /foo/bar/public_html/baz.php
$file->getRealPath();

// Retrieve file size in bytes
$file->getSize();

// Retrieve file mime type e.g. text/plain , text/html, image/gif etc.
$file->getMimeType();

// Retrieve files last modified time in "Y-m-d H:i:s" format
$file->getLastModifiedTime();

// Retrieve file contents as string
$file->getContents();

// Truncates a file to a given length
$file->truncate(10);

// Delete file contents
$file->deleteContents();

// Determine if file is readable
$file->isReadable();

// Determine if file is writable
$file->isWritable();

// Appends data
$file->append("foobarbaz");

// Create file
File::create(new Directory("foo"), "bar.txt", 0640, "foobarbaz");
```

Working with directories

```
$dir = new Directory("foo");

// Retrieves dir's real path.
$dir->path();

// Retrieves directory items, array of File and Directory instances
$dir->getItems();

// Create directory
Directory::create(Directory("foo"), "baz/qux", 0750);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

3360d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e014acd2f0c831bd8b1a91b4a10774f71122cb0b32aadfc09cc996fa7693131?d=identicon)[tsvetelin](/maintainers/tsvetelin)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/niletphp-file-system/health.svg)

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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