PHPackages                             mwstake/mediawiki-component-filestorageutilities - 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. mwstake/mediawiki-component-filestorageutilities

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

mwstake/mediawiki-component-filestorageutilities
================================================

1.0.4(3mo ago)017GPL-3.0-onlyPHP

Since Jan 15Pushed 3mo agoCompare

[ Source](https://github.com/hallowelt/mwstake-mediawiki-component-filestorageutilities)[ Packagist](https://packagist.org/packages/mwstake/mediawiki-component-filestorageutilities)[ RSS](/packages/mwstake-mediawiki-component-filestorageutilities/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

MediaWiki Stakeholders Group - Components
=========================================

[](#mediawiki-stakeholders-group---components)

File Storage Utilities Component
================================

[](#file-storage-utilities-component)

This component introduces different file backends to be used for persistent and temporary files:

- Main backend - persistent - could be S3 if system is so configured - shared between containers
- Temp backend - transient files - stored locally on disk (inside container in docker setup)

Usage
-----

[](#usage)

This component relies on MediaWiki's FileBackend implementation and following methods are just convenience methods wrapping around those.

### Shared - persistent files

[](#shared---persistent-files)

```
/** @var \MWStake\MediaWiki\Component\FileStorageUtilities\StorageHandler $service */
$service = \MediaWiki\MediaWikiServices::getInstance()
    ->get( 'MWStake.StorageUtilities' );

// Create file
$status = $service->newTransaction()
    ->create( 'myfile.txt', 'File content', 'My/Sub/Directory', [ 'overwrite' => true ] )
    ->commit();

// Retrieve file
$file = $service->getFile( 'myfile.txt', 'My/Sub/Directory' );
$file->getFilename(); // 'myfile.txt'
$file->getDirectory(); // 'My/Sub/Directory'
$file->getPath(); // Local copy => '/tmp/{hash}.txt'
$content = file_get_contents( $file->getPath() ); // 'File content'

// Delete file
$status = $service->newTransaction()
    ->delete( 'myfile.txt', 'My/Sub/Directory' )
    ->deleteDirectory( 'My/Sub/Directory' )
    ->commit();
```

### Temporary files

[](#temporary-files)

```
/** @var \MWStake\MediaWiki\Component\FileStorageUtilities\StorageHandler $service */
$service = \MediaWiki\MediaWikiServices::getInstance()
    ->get( 'MWStake.StorageUtilities' );

// Create temp file
$status = $service->newTempTransaction()
    ->create( 'mytempfile.txt', 'Temp file content', 'Temp/Dir' )
    ->commit();

// Get path of the temp file without creating it - useful for passing to objects that will write to that path
$prepare = true; // default: true to create any missing directories in path, false to just return the path
$path = $service->getTempFilePath( 'mytempfile2.txt', 'Temp/Dir', $prepare ); // configured/temp/dir/Temp/Dir/mytempfile2.txt

// Retrieving/deleting files is same as for persistent files
```

### Direct FileBackend usage

[](#direct-filebackend-usage)

In edge-cases where wrapper methods are not enough, you can use FileBackends directly

```
/** @var \MWStake\MediaWiki\Component\FileStorageUtilities\StorageHandler $service */
$service = \MediaWiki\MediaWikiServices::getInstance()
    ->get( 'MWStake.StorageUtilities' );

$type = 'main' // Shared
$type = 'temp' // Temp
$type = 'instance' // Instance

$backend = $service->getBackend( $type );
```

Configuration
-------------

[](#configuration)

Settings are to be configured in pre-init!

### Storage directory - mandatory

[](#storage-directory---mandatory)

This is the directory where all the custom files will be stored (and it sub-directories of it)

```
$GLOBALS['mwsgFileStorageDataDirectory'] = 'my-dir'
```

### AWS S3 backend ( only set to true if AWS extension is configured )

[](#aws-s3-backend--only-set-to-true-if-aws-extension-is-configured-)

```
$GLOBALS['mwsgFileStorageUseS3'] = true;
```

### Using custom backend (optional)

[](#using-custom-backend-optional)

```
$GLOBALS['mwsgFileStorageBackend'] = 'backend-name';
```

### Temp backend (optional)

[](#temp-backend-optional)

In addition to main, persistent backend, a temporary backend can be used for transient files. This backend saves files to a temp directory within container. Default: `wgTmpDirectory`

Note: Temp backend is shared between instances (in a farm setup), so no per-instance sub-dir.

```
$GLOBALS['mwsgFileStorageLocalTempDir'] = '/path/to/temp/dir';
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance82

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Total

5

Last Release

95d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/161c38b5448b71865cf0652b6974ed489dd3683b5d6e1814973cea6cb66c8f1d?d=identicon)[dsavuljesku](/maintainers/dsavuljesku)

---

Top Contributors

[![it-spiderman](https://avatars.githubusercontent.com/u/13665198?v=4)](https://github.com/it-spiderman "it-spiderman (8 commits)")

### Embed Badge

![Health badge](/badges/mwstake-mediawiki-component-filestorageutilities/health.svg)

```
[![Health](https://phpackages.com/badges/mwstake-mediawiki-component-filestorageutilities/health.svg)](https://phpackages.com/packages/mwstake-mediawiki-component-filestorageutilities)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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