PHPackages                             jaxon-php/jaxon-storage - 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. jaxon-php/jaxon-storage

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

jaxon-php/jaxon-storage
=======================

File storage for the Jaxon ajax PHP library

v1.2.3(2mo ago)0962↑167.9%3BSD-3-ClausePHPPHP &gt;=8.0CI passing

Since Dec 3Pushed 2mo agoCompare

[ Source](https://github.com/jaxon-php/jaxon-storage)[ Packagist](https://packagist.org/packages/jaxon-php/jaxon-storage)[ Docs](https://www.jaxon-php.org)[ RSS](/packages/jaxon-php-jaxon-storage/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (6)Dependencies (16)Versions (7)Used By (3)

[![Build Status](https://github.com/jaxon-php/jaxon-storage/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/jaxon-php/jaxon-storage/actions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/95231ac8d9f0c0cbc26195a52b090cc794e14e1121f4ace9a2f74f5ff056e088/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/jaxon-php/jaxon-storage/?branch=main)[![StyleCI](https://camo.githubusercontent.com/96f903e4e4446faf7a1f60515e162bea489141c5a1c6fb25186c5029b7cadf2e/68747470733a2f2f7374796c6563692e696f2f7265706f732f313130393038343739342f736869656c643f6272616e63683d6d61696e)](https://styleci.io/repos/1109084794)[![codecov](https://camo.githubusercontent.com/e1d9c626047c4ef323fc249ecf68fd41186ebb018a51ba3550a54f034a15cd94/68747470733a2f2f636f6465636f762e696f2f67682f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f67726170682f62616467652e7376673f746f6b656e3d4f46795439577a567874)](https://codecov.io/gh/jaxon-php/jaxon-storage)

[![Latest Stable Version](https://camo.githubusercontent.com/e5b617ef1107aa76830d6e3e1f30e0f37ee439e1d967b805479493b467e06070/68747470733a2f2f706f7365722e707567782e6f72672f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f762f737461626c65)](https://packagist.org/packages/jaxon-php/jaxon-storage)[![Total Downloads](https://camo.githubusercontent.com/4c80ee2b73d1d440f29301253dd19c4c9ca01a10b0c702920bd0e5d4f7aa6ead/68747470733a2f2f706f7365722e707567782e6f72672f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f646f776e6c6f616473)](https://packagist.org/packages/jaxon-php/jaxon-storage)[![Latest Unstable Version](https://camo.githubusercontent.com/c88dc33c7f2dcf39888401513e4da6cefcd51b91c423116f290543c643db98fb/68747470733a2f2f706f7365722e707567782e6f72672f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f762f756e737461626c65)](https://packagist.org/packages/jaxon-php/jaxon-storage)[![License](https://camo.githubusercontent.com/eced226313a8ccc2c508afecac7e4b7b0d1cde0077972758a04e13cdbf862eff/68747470733a2f2f706f7365722e707567782e6f72672f6a61786f6e2d7068702f6a61786f6e2d73746f726167652f6c6963656e7365)](https://packagist.org/packages/jaxon-php/jaxon-storage)

File storage for the Jaxon library
==================================

[](#file-storage-for-the-jaxon-library)

This package provides a tiny wrapper for file storage for the Jaxon library using the [PHP League Flysystem](https://flysystem.thephpleague.com) library.

Features
--------

[](#features)

The library features are provided in the `Jaxon\Storage\StorageManager` class, which implements three functions.

Starting from version 1.1.0, a global function is available to get the instance of the storage manager.

```
use function Jaxon\Storage\storage;
```

This function creates and returns a static instance of the `Jaxon\Storage\StorageManager` class.

#### Register an adapter

[](#register-an-adapter)

This function registers an adapter from the [Flysystem](https://flysystem.thephpleague.com) library.

```
    /**
     * @param string $sAdapter
     * @param Closure $cFactory
     *
     * @return void
     */
    public function register(string $sAdapter, Closure $cFactory)
```

The first parameter is the adapter id, and the second is a closure which takes a root dir and an optional array of options as parameters, and returns a `League\Flysystem\FilesystemAdapter` object configured for file input and output at the given location.

By default, the library registers an adapter for the local filesystem.

```
use League\Flysystem\Local\LocalFilesystemAdapter;
use function Jaxon\Storage\storage;

// Local file system adapter
storage()->register('local', function(string $sRootDir, array $aOptions) {
    return new LocalFilesystemAdapter($sRootDir, ...$aOptions);
});
```

An adapter can be registered as an alias of an already registered one. This is useful for example for using the same adapter with different options.

```
use function Jaxon\Storage\storage;

// The "uploads" adapter is an alias of the local file system adapter
storage()->register('uploads', 'local');
```

#### Create a file input/output object

[](#create-a-file-inputoutput-object)

A [Flysystem](https://flysystem.thephpleague.com) object for file input and output is created by chaining the `adapter()` and `make()` functions.

```
use function Jaxon\Storage\storage;

$storage = storage()
    ->adapter('local')
    ->make('/var/www/storage/uploads');
$storage->write('uploaded-file.txt', $uploadedContent)
```

The `adapter()` function takes the id of a registered adapter as parameter, while the `make()` function takes the path to the root dir.

The code snippet below writes the given content in the `/var/www/storage/uploads/uploaded-file.txt` file.

The adapter and directory options can be passed to the `adapter()` and `make()` functions. The adapter options are set on the adapter object (e.g `LocalFilesystemAdapter`), while the directory options are set on the returned `Filesystem` object. Their values are then described in their respective documentations.

```
use function Jaxon\Storage\storage;

$aAdapterOptions = [
    'lazyRootCreation' => true,
];
$aDirOptions = [
    'config' => [
        'public_url' => '/uploads',
    ],
];
$storage = storage()
    ->adapter('local', $aAdapterOptions)
    ->make('/var/www/storage/uploads', $aDirOptions);
$storage->write('uploaded-file.txt', $uploadedContent)
```

#### Create a file input/output object from a Jaxon Config object

[](#create-a-file-inputoutput-object-from-a-jaxon-config-object)

The [Flysystem](https://flysystem.thephpleague.com) object for file input and output can also be created from option values in a `Jaxon\Config\Config` object. For the storage with id `uploads`, the `adapter`, `dir` and `options` values will be read in the `storage.stores.uploads` entry.

```
use Jaxon\Config\ConfigSetter;
use function Jaxon\Storage\storage;

// Set the storage config
$setter = new ConfigSetter();
$config = $setter->newConfig([
    'storage' => [
        'adapters' => [
            // Adapters options
            'local' => [], // Optional
        ]
        'stores' => [
            'uploads' => [
                'adapter' => 'local',
                'dir' => '/var/www/storage/uploads',
                // 'options' => [], // Optional
            ],
        ],
    ],
]);
storage()->setConfig($config);

// Write a file
$storage = storage()->get('uploads');
$storage->write('uploaded-file.txt', $uploadedContent)
```

The code snippet above writes the given content in the `/var/www/storage/uploads/uploaded-file.txt` file, as in the previous example.

```
use function Jaxon\Storage\storage;

$storage = storage()->get('uploads');
$storage->write('uploaded-file.txt', $uploadedContent)
```

Each adapter can also be defined as an alias of an already defined adapter.

```
$config = $setter->newConfig([
    'storage' => [
        'adapters' => [
            // Adapters options
            'uploads' => [
                'alias' => 'local',
                'options' => [], // Local adapter options for the uploads
            ],
            'exports' => [
                'alias' => 'local',
                'options' => [], // Local adapter options for the exports
            ],
        ],
        'stores' => [],
    ],
]);
```

Using without the Jaxon library
-------------------------------

[](#using-without-the-jaxon-library)

Starting from version 1.1.0, the Jaxon Storage classes do not depend on the [jaxon-core](https://github.com/jaxon-php/jaxon-core) classes anymore. As a consequence, some features will not be automatically available, and will need an extra setup.

#### The locale for translations

[](#the-locale-for-translations)

Without the [jaxon-core](https://github.com/jaxon-php/jaxon-core) library, the Jaxon Storage will create its own instance of the `Jaxon\Utils\Translation\Translator` class, which will then need to be set.

```
use function Jaxon\Storage\storage;

// Set the translation locle to french.
storage()->translator()->setLocale('fr');
```

#### The storage config options

[](#the-storage-config-options)

A call to the `storage()->get()` function will by default throw an exception due to missing config options. The library then needs to be provided with a `Jaxon\Config\Config` object populated with the config options, or a closure which returns one, using the `setConfig()` method.

Register additional adapters
----------------------------

[](#register-additional-adapters)

The [Flysystem](https://flysystem.thephpleague.com) library provides adapters for many other filesystems, which can be registered with this library.

They are provided in separate packages, which need to be installed first.

#### AWS S3 file system adapter

[](#aws-s3-file-system-adapter)

```
use Aws\S3\S3Client;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use function Jaxon\Storage\storage;

storage()->register('aws-s3', function(string $sRootDir, array $aOptions) {
    $client = new S3Client($aOptions['client'] ?? []);
    return new AwsS3V3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
});
```

#### Async AWS S3 file system adapter

[](#async-aws-s3-file-system-adapter)

```
use AsyncAws\S3\S3Client;
use League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter;
use function Jaxon\Storage\storage;

storage()->register('async-aws-s3', function(string $sRootDir, array $aOptions) {
    $client = isset($aOptions['client']) ? new S3Client($aOptions['client']) : new S3Client();
    return new AsyncAwsS3Adapter($client, $aOptions['bucket'] ?? '', $sRootDir);
});
```

#### Google Cloud file system adapter

[](#google-cloud-file-system-adapter)

```
use Google\Cloud\Storage\StorageClient;
use League\Flysystem\AzureBlobStorage\GoogleCloudStorageAdapter;
use function Jaxon\Storage\storage;

storage()->register('google-cloud', function(string $sRootDir, array $aOptions) {
    $storageClient = new StorageClient($aOptions['client'] ?? []);
    $bucket = $storageClient->bucket($aOptions['bucket'] ?? '');
    return new GoogleCloudStorageAdapter($bucket, $sRootDir);
});
```

#### Microsoft Azure file system adapter

[](#microsoft-azure-file-system-adapter)

```
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use function Jaxon\Storage\storage;

storage()->register('azure-blob', function(string $sRootDir, array $aOptions) {
    $client = BlobRestProxy::createBlobService($aOptions['dsn']);
    return new AzureBlobStorageAdapter($client, $aOptions['container'], $sRootDir);
});
```

#### FTP file system adapter

[](#ftp-file-system-adapter)

```
use League\Flysystem\Ftp\FtpAdapter;
use League\Flysystem\Ftp\FtpConnectionOptions;
use function Jaxon\Storage\storage;

storage()->register('ftp', function(string $sRootDir, array $aOptions) {
    $aOptions['root'] = $sRootDir;
    $xOptions = FtpConnectionOptions::fromArray($aOptions);
    return new FtpAdapter($xOptions);
});
```

#### SFTP V2 file system adapter

[](#sftp-v2-file-system-adapter)

```
use League\Flysystem\PhpseclibV2\SftpAdapter;
use League\Flysystem\PhpseclibV2\SftpConnectionProvider;
use function Jaxon\Storage\storage;

storage()->register('sftp-v2', function(string $sRootDir, array $aOptions) {
    $provider = new SftpConnectionProvider(...$aOptions);
    return new SftpAdapter($provider, $sRootDir);
});
```

#### SFTP V3 file system adapter

[](#sftp-v3-file-system-adapter)

```
use League\Flysystem\PhpseclibV3\SftpAdapter;
use League\Flysystem\PhpseclibV3\SftpConnectionProvider;
use function Jaxon\Storage\storage;

storage()->register('sftp-v3', function(string $sRootDir, array $aOptions) {
    $provider = new SftpConnectionProvider(...$aOptions);
    return new SftpAdapter($provider, $sRootDir);
});
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

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

Total

6

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebb668d7515d81741c86e42cf3194f5623636fbb15dd5412e26ea8320865d229?d=identicon)[lagdo](/maintainers/lagdo)

---

Top Contributors

[![feuzeu](https://avatars.githubusercontent.com/u/15174329?v=4)](https://github.com/feuzeu "feuzeu (23 commits)")

---

Tags

phpstorageajaxJaxon

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jaxon-php-jaxon-storage/health.svg)

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

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

74149.4k30](/packages/jaxon-php-jaxon-core)

PHPackages © 2026

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