PHPackages                             samsonphp/fs - 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. samsonphp/fs

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

samsonphp/fs
============

SamsonPHP file system service

1.1.11(11y ago)33.5k2Open Software License (OSL) v 3.0PHP

Since Nov 23Pushed 9y ago2 watchersCompare

[ Source](https://github.com/SamsonPHP/fs)[ Packagist](https://packagist.org/packages/samsonphp/fs)[ Docs](http://samsonos.com/)[ RSS](/packages/samsonphp-fs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (19)Used By (2)

\#SamsonPHP File service

[![Latest Stable Version](https://camo.githubusercontent.com/b71cf9c74be20217634122e551ead09855e7c710577558f1263147963884ec27/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e7068702f66732f762f737461626c652e737667)](https://packagist.org/packages/samsonphp/fs)[![Build Status](https://camo.githubusercontent.com/85c09af8ad9297490ccf140e93a56d52d12d32bc0a38f40c3fc32ff1f64708b0/68747470733a2f2f7472617669732d63692e6f72672f53616d736f6e5048502f66732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SamsonPHP/fs)[![Code Coverage](https://camo.githubusercontent.com/49d4e8bd166b47d924da0fb7a7b7a9d11bc260484b020d7516533112dd99a9c2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e7068702f66732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonphp/fs/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7b7e36b6e2c6f48a31e95698891dec7e321b09e2c316bd53eb8b10db0eea3e88/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e7068702f66732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonphp/fs/?branch=master)[![Stories in Ready](https://camo.githubusercontent.com/c785977eadf4e9d6e44e225411de470a317321ba504b5e8efbfe7b744145143a/68747470733a2f2f62616467652e776166666c652e696f2f73616d736f6e7068702f66732e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/samsonphp/fs)[![Total Downloads](https://camo.githubusercontent.com/8e45dc35c647cb7b488b76b3c2959dbe316ca2dffd319096b7cc77d8d5a94c15/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e7068702f66732f646f776e6c6f6164732e737667)](https://packagist.org/packages/samsonphp/fs)

This module gives abstraction level for working with file system independently of what exact file system is being used.

\##Configuration

The main goal is to configure the `$fileServiceClassName`service parameter.

This is usually done using [SamsonPHP module/service configuration](https://github.com/samsonphp/config)

By default `$fileServiceClassName` is set to `samsonphp\fs\LocalFileService` - it uses standard local file system service. This parameter has to be set to file service class name, for example - local file service - `samsonphp\fs\LocalFileService`, no module/service identifiers or anything else should be used, first namespace separator `\` should be avoided too:

- `\samsonphp\fs\LocalFileService` - incorrect
- `samsonphp\fs\LocalFileService` - correct

> When service is initialized it checks if configured file service class is present otherwise fatal error is signaled.

This gives you ability, for example, to quickly change your web-application file system from local file system to Amazon Web Services S3 bucket, which is implemented by [SamsonPHP AWS file service `fs_aws`](http://github.com/samsonphp/fs_aws). All you have to do is add configuration for this SamsonPHP file service(`fs`):

```
class FileServiceConfig extends \samson\core\Config
{
  /**@var string Configured module/service identifier */
  public $__id = 'fs';

  /**@var string Set Amazon Web Services as web-application file service using its identifier */
  public $fileServiceID = 'samsonphp\fs\AWSFileService';
}
```

Usage
-----

[](#usage)

To work with this SamsonPHP file service you should get file service instance pointer:

```
/**@var \samsonphp\fs\FileService $fs Pointer to file service */
$fs = & m('fs');
```

After this you can use all available methods from [`AbstractFileService` interface](https://github.com/samsonphp/fs/blob/master/src/IFileSystem.php), which this SamsonPHP file service(`fs`) implements. All this method call act like a proxy and passes them to currently configured file service(by default `php_fs_local`).

Example usage:

```
if (!$fs->exists(...)) {
  $fs->write(...);
}
```

### Using service in tests

[](#using-service-in-tests)

First of all you should create service instance:

```
// Create instance
$this->fileService = new FileService(__DIR__.'../');
```

In other places called after service creation you should retrieve service object via factory method:

```
// Get instance using services factory as error will signal other way
$this->fileService = \samson\core\Service::getInstance('samsonphp\fs\FileService');
```

> All other SamsonPHP modules must and use this file service approach when working with files.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 89.1% 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 ~3 days

Total

18

Last Release

4134d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6510135856527278a1da14ea26ecaa3f016c27604236cec14ee550a8441dec52?d=identicon)[samsonphp](/maintainers/samsonphp)

---

Top Contributors

[![vitalyiegorov](https://avatars.githubusercontent.com/u/586558?v=4)](https://github.com/vitalyiegorov "vitalyiegorov (196 commits)")[![nik-os](https://avatars.githubusercontent.com/u/7326967?v=4)](https://github.com/nik-os "nik-os (11 commits)")[![onysko](https://avatars.githubusercontent.com/u/7703953?v=4)](https://github.com/onysko "onysko (10 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![omaximus](https://avatars.githubusercontent.com/u/8122734?v=4)](https://github.com/omaximus "omaximus (1 commits)")

---

Tags

file systemsamsonphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samsonphp-fs/health.svg)

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

###  Alternatives

[igorw/file-serve-bundle

Symfony2 Bundle for serving protected files.

166156.5k](/packages/igorw-file-serve-bundle)[crysalead/dir

Recursive directory scanner to locate directories and/or files in a file system

13214.5k4](/packages/crysalead-dir)[aimeos/ai-filesystem

Aimeos file system layer extension

1029.9k1](/packages/aimeos-ai-filesystem)

PHPackages © 2026

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