PHPackages                             samsonos/php\_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. samsonos/php\_fs

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

samsonos/php\_fs
================

SamsonPHP file system service

1.1.7(11y ago)452932Open Software License (OSL) v 3.0PHP

Since Nov 23Pushed 11y ago2 watchersCompare

[ Source](https://github.com/samsonos/php_fs)[ Packagist](https://packagist.org/packages/samsonos/php_fs)[ Docs](http://samsonos.com/)[ RSS](/packages/samsonos-php-fs/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (15)Used By (2)

\#SamsonPHP File service

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

[![Latest Stable Version](https://camo.githubusercontent.com/b7eb28fd5b2a3aa9f127657b46941b8f3a8959cecd44c109f0b9c08ad211c221/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6f732f7068705f66732f762f737461626c652e737667)](https://packagist.org/packages/samsonos/php_fs)[![Build Status](https://camo.githubusercontent.com/5ec4d1389c1289150f1c9ec9e332d626a6ba0466981b4b1b4aa6201b2721e884/68747470733a2f2f7472617669732d63692e6f72672f73616d736f6e6f732f7068705f66732e706e67)](https://travis-ci.org/samsonos/php_fs)[![Code Coverage](https://camo.githubusercontent.com/d5e016e255ee2cedffa10c3fad3fc2691b420ab7d5e77941b658a72eab296373/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e6f732f7068705f66732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonos/php_fs/?branch=master)[![Code Climate](https://camo.githubusercontent.com/03d648fb7a320fa4c31cde87f25a5fdd3e5104132f02dba2a4a0bb7787ae93f0/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73616d736f6e6f732f7068705f66732f6261646765732f6770612e737667)](https://codeclimate.com/github/samsonos/php_fs)[![Total Downloads](https://camo.githubusercontent.com/a6488d900cd9e6b4439ea712656f4deba5089610b25d7d0f696db731efccaf0f/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6f732f7068705f66732f646f776e6c6f6164732e737667)](https://packagist.org/packages/samsonos/php_fs)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8754710e5a43cc0df608f6fd9cec58360e1aa473d7425b792e8313032b90f0d4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616d736f6e6f732f7068705f66732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/samsonos/php_fs/?branch=master)[![Stories in Ready](https://camo.githubusercontent.com/b6ae9a71b23c5ec0c71f55c58d119df01b42226d12b9c5b296c2654fd6aaed81/68747470733a2f2f62616467652e776166666c652e696f2f73616d736f6e6f732f7068705f66732e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/samsonos/php_compressor)

\##Configuration

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

This is usually done using [SamsonPHP module/service configuration](https://github.com/samsonos/php_fs/wiki/0.3-Configurating)

By default `$fileServiceClassName` is set to `samson\fs\LocalFileService` - it uses standard local file system service which is implemented by [SamsonPHP local file service `php_fs_local`](http://github.com/samsonos/php_fs_local). This parameter has to be set to file service class name, for example - local file service - `samson\fs\LocalFileService`, no module/service identifiers or anything else should be used, first namespace separator `\` should be avoided too:

- `\samson\fs\LocalFileService` - incorrect
- `samson\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 `php_fs_aws`](http://github.com/samsonos/php_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 = 'samson\fs\AWSFileService';
}
```

Usage
-----

[](#usage)

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

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

After this you can use all available methods from [`AbstractFileService` interface](https://github.com/samsonos/php_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('samson\fs\FileService');
```

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

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 88.8% 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

14

Last Release

4191d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0be8756efdc8f599b8fe9261bed31570d0f140a3b921f0f891877a9133ad654c?d=identicon)[samsonos](/maintainers/samsonos)

---

Top Contributors

[![vitalyiegorov](https://avatars.githubusercontent.com/u/586558?v=4)](https://github.com/vitalyiegorov "vitalyiegorov (175 commits)")[![onysko](https://avatars.githubusercontent.com/u/7703953?v=4)](https://github.com/onysko "onysko (10 commits)")[![nik-os](https://avatars.githubusercontent.com/u/7326967?v=4)](https://github.com/nik-os "nik-os (9 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/samsonos-php-fs/health.svg)

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

###  Alternatives

[igorw/file-serve-bundle

Symfony2 Bundle for serving protected files.

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

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

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

Aimeos file system layer extension

1032.6k2](/packages/aimeos-ai-filesystem)

PHPackages © 2026

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