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

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

originphp/filesystem
====================

OriginPHP Filesystem

3.1.0(5y ago)12.3k5MITPHPPHP &gt;=7.3.0CI failing

Since Oct 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/originphp/filesystem)[ Packagist](https://packagist.org/packages/originphp/filesystem)[ Docs](https://www.originphp.com)[ RSS](/packages/originphp-filesystem/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (9)Used By (5)

Filesystem
==========

[](#filesystem)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/originphp/filesystem/workflows/CI/badge.svg)](https://github.com/originphp/filesystem/actions)[![coverage](https://camo.githubusercontent.com/7366b33bf0a16e2406993ccde8b5357d4748447ac5b3fc2081ce09f60515dba9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f726967696e7068702f66696c6573797374656d2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/originphp/filesystem?branch=master)

Filesystem includes the `File` and `Folder` classes for working with your filesystem.

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

[](#installation)

To install this package

```
$ composer require originphp/filesystem

```

File
----

[](#file)

he file utility wraps some important functions in an easy to use and predictable way.

To use the File utility add the following to the top of your file.

```
use Origin\Filesystem\File
```

### Info

[](#info)

> As of 2.0 path was renamed to directory and filename was renamed to name

To get information about a file

```
$info = File::info('/var/www/config/insurance.csv');
```

Which will return an array like this

```
Array
(
    [name] => insurance.csv
    [directory] => /var/www/config
    [timestamp] => 1560067334
    [size] => 1878
    [extension] => csv
    [type] => text/plain
)

```

### Read

[](#read)

To read a file

```
$contents = File::read('/path/somefile');
```

### Write

[](#write)

To write to a file

```
File::write('/path/somefile','data goes here');
```

### Append

[](#append)

To append contents to a file

```
File::append('/path/somefile','and here.');
```

### Delete

[](#delete)

To delete a file

```
File::delete('/path/somefile');
```

### Exists

[](#exists)

To check if file exists

```
$result = File::exists('/path/somefile');
```

### Tmp

[](#tmp)

When needing to work with temporary files, use tmp, this will create the file, put the contents and return to you the name of the file with path.

```
$tmpFile = File::tmp('Some temp data');
```

### Copy

[](#copy)

To copy a file

```
File::copy('/path/somefile','somefile-backup');
File::copy('/path/somefile','/another_path/somefile');
```

### Rename

[](#rename)

To rename a file

```
File::rename('/path/somefile','new_name');
```

### Move

[](#move)

To move a file

```
File::move('/path/somefile','/another_path/somefile');
```

### Permissions

[](#permissions)

#### Get Permissions

[](#get-permissions)

To get the permissions of a file

```
$permissions = File::perms('/path/somefile'); // returns 0744
```

#### Changing Permissions (chmod)

[](#changing-permissions-chmod)

To change the permissions of a file.

```
File::chmod('/path/somefile','www-data');
```

#### Getting the owner of the file

[](#getting-the-owner-of-the-file)

```
$owner = File::owner('/path/somefile'); // returns root
```

#### Changing Ownership (chown)

[](#changing-ownership-chown)

To change the ownership of a file

```
File::chown('/path/somefile','www-data');
```

#### Getting the group

[](#getting-the-group)

To get the group that the file belongs to.

```
$group = File::group('/path/somefile'); // returns root
```

#### Changing Group (chgrp)

[](#changing-group-chgrp)

To change the group that the file belongs to.

```
File::chgrp('/path/somefile','www-data');
```

Folder
------

[](#folder)

The folder utility helps you work with folders on your file system.

To use the Folder utility add the following to the top of your file.

```
use Origin\Filesystem\Folder
```

### Create

[](#create)

To create a folder

```
Folder::create('/var/www/new_folder');
```

To create a folder recursively

```
Folder::create('/var/www/level1/level2/level3/new_folder',['recursive'=>true]);
```

To set the permissions on the newly created folder

```
Folder::create('/var/www/new_folder',['mode'=>0755]);
```

### Delete

[](#delete-1)

To delete a folder

```
Folder::delete('/var/www/bye-bye')
```

To delete a folder recursively, including all files and sub directories.

```
Folder::delete('/var/www/docs',['recursive'=>true])
```

### Exists

[](#exists-1)

To check if a directory exists

```
$result = Folder::exists('/path/somedirectory');
```

### List

[](#list)

> As of version 2.0 released 26.09.20 list results are different, path now includes the filename.

To list all contents of a directory

```
$results = Folder::list('/path/somedirectory');
```

This will return an array of arrays of `FileObjects`

```
[
    Origin\Filesystem\FileObject Object
    (
        'name' => 'foo.txt',
        'directory' => '/var/www/my_directory',
        'path' =>  '/var/www/my_directory/foo.txt',
        'extension' => 'txt',
        'timestamp' => 14324234,
        'size' => 1234,
        'type' => 'file'
    )
]
```

When the `FileObject` is converted to a string it will become a path e.g. `/var/www/my_directory/foo.txt`.

```
foreach(Folder::list('/data') as $file){
    $contents = file_get_contents($file->path); // or (string) $file
}
```

You can also get the listing recursively

```
$results = Folder::list('/path/somedirectory',['recursive'=>true]);
```

To include directories in the results

```
$results = Folder::list('/path/somedirectory',['directories'=>true]);
```

### Copy

[](#copy-1)

To copy a directory

```
Folder::copy('/path/somedir','somedir-backup');
Folder::copy('/path/somedir','/another_path/somedir');
```

### Rename

[](#rename-1)

To rename a directory

```
Folder::rename('/path/somedir','new_name');
```

### Move

[](#move-1)

To move a directory

```
Folder::move('/path/somedir','/another_path/somedir');
```

### Permissions

[](#permissions-1)

#### Get Permissions

[](#get-permissions-1)

To get the permissions of a directory.

```
$permissions = Folder::perms('/path/somedir'); // returns 0744
```

#### Changing Permissions (chmod)

[](#changing-permissions-chmod-1)

To change the permissions of a directory

```
Folder::chmod('/path/somedir','www-data');
Folder::chmod('/path/somedir','www-data',['recursive'=>true]); // recursive
```

#### Getting the owner of a directory

[](#getting-the-owner-of-a-directory)

```
$owner = Folder::owner('/path/somedir'); // returns root
```

#### Changing Ownership (chown)

[](#changing-ownership-chown-1)

To change the ownership of a directory

```
Folder::chown('/path/somedir','www-data');
Folder::chown('/path/somedir','www-data',['recursive'=>true]);
```

#### Getting the group

[](#getting-the-group-1)

To get the group that a directory belongs to.

```
$group = Folder::group('/path/somedir'); // returns root
```

#### Changing Group (chgrp)

[](#changing-group-chgrp-1)

To change the group that the folder belongs to.

```
Folder::chgrp('/path/somedir','www-data');
Folder::chgrp('/path/somedir','www-data',['recursive'=>true]);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~78 days

Recently: every ~42 days

Total

8

Last Release

1897d ago

Major Versions

1.0.0 → 2.0.02020-09-26

2.0.2 → 3.0.02021-01-04

PHP version history (3 changes)1.0.0PHP ^7.2.0

2.0.2PHP &gt;=7.2.0

3.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8a821333d9c7b7bc2ad3d164d142f65cd3912dea78033d31f76b0f19ba8a0c?d=identicon)[originphp](/maintainers/originphp)

---

Top Contributors

[![jamielsharief](https://avatars.githubusercontent.com/u/20553479?v=4)](https://github.com/jamielsharief "jamielsharief (26 commits)")

---

Tags

filesystemfilefolderoriginPHPchmodchgrpchown

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k665.7M2.4k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k277.8M959](/packages/league-flysystem-aws-s3-v3)[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k40.9M129](/packages/knplabs-gaufrette)[knplabs/knp-gaufrette-bundle

Allows to easily use the Gaufrette library in a Symfony project

72429.6M99](/packages/knplabs-knp-gaufrette-bundle)[league/flysystem-local

Local filesystem adapter for Flysystem.

224254.9M71](/packages/league-flysystem-local)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8535.9M247](/packages/league-flysystem-memory)

PHPackages © 2026

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