PHPackages                             alex-kalanis/kw\_files - 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. alex-kalanis/kw\_files

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

alex-kalanis/kw\_files
======================

Accessing stored entries as files on some volume

v5.0.0(1y ago)02.6k14BSD-3-ClausePHPPHP &gt;=7.4.0CI passing

Since Sep 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alex-kalanis/kw_files)[ Packagist](https://packagist.org/packages/alex-kalanis/kw_files)[ RSS](/packages/alex-kalanis-kw-files/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (7)Versions (24)Used By (14)

kw\_files
=========

[](#kw_files)

[![Build Status](https://github.com/alex-kalanis/kw_storage/actions/workflows/code_checks.yml/badge.svg)](https://github.com/alex-kalanis/kw_storage/actions/workflows/code_checks.yml/badge.svg)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b4b935f459532d484f2f2eccd1d9ebca9f2581559b4153eacb5896f8ddb5c546/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f6b775f66696c65732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alex-kalanis/kw_files/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/822c0b4db66d0b3555eaa285064d65b43640fb8daadeb46840c69cfdee95632e/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f6b775f66696c65732f762f737461626c652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/kw_files)[![Minimum PHP Version](https://camo.githubusercontent.com/0e9ac047546796cfdbe1423d1f4d91c8f37d2fbb11614a7900bb7686aaa5401f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d3838393242462e737667)](https://php.net/)[![Downloads](https://camo.githubusercontent.com/bb4a677a8ee067b70df63eff28969dd458dcad793cdf5b3cca12dccb9200972c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c65782d6b616c616e69732f6b775f66696c65732e7376673f7631)](https://packagist.org/packages/alex-kalanis/kw_files)[![License](https://camo.githubusercontent.com/717472b0ceebec3c17d2a1b3eef2f3410280afc332f89318f71ccd9ccac44cb9/68747470733a2f2f706f7365722e707567782e6f72672f616c65782d6b616c616e69732f6b775f66696c65732f6c6963656e73652e7376673f763d31)](https://packagist.org/packages/alex-kalanis/kw_files)[![Code Coverage](https://camo.githubusercontent.com/e8b424d19e08663f243c5ccafd440c1debc7380a433d94aef1a0f8a1ecdb93d4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65782d6b616c616e69732f6b775f66696c65732f6261646765732f636f7665726167652e706e673f623d6d617374657226763d31)](https://scrutinizer-ci.com/g/alex-kalanis/kw_files/?branch=master)

Manage access to storage with emulation of tree structure of real filesystem. Necessary for key-value storages. It can also behave the correct way when storing data on classical filesystems. Basically it equalize access to storage structure as tree without need to care if it is an actual tree.

PHP Installation
----------------

[](#php-installation)

```
composer.phar require alex-kalanis/kw_files
```

(Refer to [Composer Documentation](https://github.com/composer/composer/blob/master/doc/00-intro.md#introduction) if you are not familiar with composer)

PHP Usage
---------

[](#php-usage)

1.) Use your autoloader (if not already done via Composer autoloader)

2.) Add some external packages with connection to the local or remote storages. If you use local volume you can skip this step. If you use memory as storage (like for tests) you also need underlying package `kw_storage`. Or package which implements local interfaces for things like AWS or your custom CDN.

3.) Connect the correct processing libraries into your app. The correct one depends on your storage. You can use directly `kalanis\kw_files\Access\Factory` with pass of configuration values which set the correct adapter. Or in your DI set the implementing classes of interfaces from `kalanis\kw_files\Interfaces`which will access your storage and use them in custom extension of `kalanis\kw_files\Access\CompositeAdapter`. This is the way when you use more storages at once. Each storage will have own instance of adapter.

4.) Call adapter via DI and use storage to access files. Beware that paths are defined as arrays of strings. The final separator of each level in tree depends on your storage! This way it is possible to emulate trees even on flat key-value storages.

```
// DI-like
return function (array $params): \kalanis\kw_files\Access\CompositeAdapter {
    return (new \kalanis\kw_files\Access\Factory())->getClass($params);
}
```

```
// Classes
use \kalanis\kw_files\Access;

class FileOperations
{
    public function __construct(
        // ...
        protected readonly Access\CompositeAdapter $files,
        // ...
    ) {}

    public function upload(string $name, string $content): bool
    {
        $objName = (new \kalanis\kw_paths\ArrayPath())->setString($name);
        if (!$this->files->isDir($objName->getArrayDirectory())) {
            return false;
        }
        if ($this->files->exists($objName->getArray())) {
            return false;
        }
        return $this->files->saveFile($objName->getArray(), $content);
    }

    public function move(string $from, string $to): bool
    {
        $arrFrom = (new \kalanis\kw_paths\ArrayPath())->setString($from)->getArray();
        $objTo = (new \kalanis\kw_paths\ArrayPath())->setString($to);
        if (!$this->files->exists($arrFrom)) {
            return false;
        }
        if (!$this->files->exists($objTo->getArrayDirectory())) {
            return false;
        }
        if ($this->files->exists($objTo->getArray())) {
            return false;
        }
        return $this->files->isDir($arrFrom)
            ? $this->files->moveDir($arrFrom, $objTo->getArray())
            : $this->files->moveFile($arrFrom, $objTo->getArray())
        ;
    }
}
```

### Changes

[](#changes)

- 5.0 - uses DateTime, tests with separated classes
- 4.0 - changed behavior against streams
- 3.0 - has extended support of actions over files, got some things from other repositories
- 2.0 - has difference in interface and class tree building for free name lookup
- 1.0 - initial version

Notes to self: - all entries starts internally with the separators (usually slashes). It is not necessary and sometimes counter-productive to add them when setting the starting dir. It behaves like a prefix.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance46

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity57

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

Recently: every ~95 days

Total

23

Last Release

416d ago

Major Versions

v1.1.1 → v2.0.02022-12-27

v2.2.0 → v3.0.02023-05-08

v3.5.3 → v4.0.02024-03-31

v4.1.2 → v5.0.02025-05-06

PHP version history (2 changes)v1.0.0PHP &gt;=7.2.0

v4.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59184183?v=4)[Petr Plsek](/maintainers/alex-kalanis)[@alex-kalanis](https://github.com/alex-kalanis)

---

Top Contributors

[![alex-kalanis](https://avatars.githubusercontent.com/u/59184183?v=4)](https://github.com/alex-kalanis "alex-kalanis (52 commits)")

---

Tags

filefilesvolume

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alex-kalanis-kw-files/health.svg)

```
[![Health](https://phpackages.com/badges/alex-kalanis-kw-files/health.svg)](https://phpackages.com/packages/alex-kalanis-kw-files)
```

###  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.8M961](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

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

In-memory filesystem adapter for Flysystem.

8535.9M248](/packages/league-flysystem-memory)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6133.1M132](/packages/league-flysystem-sftp-v3)[league/flysystem-ziparchive

ZIP filesystem adapter for Flysystem.

1039.6M71](/packages/league-flysystem-ziparchive)

PHPackages © 2026

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