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

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

originphp/storage
=================

OriginPHP Storage

3.1.0(5y ago)2670[2 issues](https://github.com/originphp/storage/issues)1MITPHPPHP &gt;=7.3.0CI failing

Since Oct 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/originphp/storage)[ Packagist](https://packagist.org/packages/originphp/storage)[ Docs](https://www.originphp.com)[ RSS](/packages/originphp-storage/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (6)Versions (16)Used By (1)

Storage
=======

[](#storage)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/originphp/storage/workflows/CI/badge.svg)](https://github.com/originphp/storage/actions)[![coverage](https://camo.githubusercontent.com/fe39735face20c85330eb0f4a7b9d25a367c0ae2b41661d3ab36f994e6033129/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f726967696e7068702f73746f726167652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/originphp/storage?branch=master)

The Storage library provides an easy way to access different types of storages from local disk, ZIP archives, FTP and SFTP. Its a unified approach for working with different storages.

Installation
------------

[](#installation)

To install this package

```
$ composer require originphp/storage

```

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

[](#configuration)

You need to configure the default storage engine, you can use multiple engines, but there must be a default one.

In your bootstrap/configuration files add

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\LocalEngine;

Storage::config('default', [
    'className' => LocalEngine::class
    'root' => '/var/www/storage'
]);
```

Using Storage
-------------

[](#using-storage)

### Writing To Storage

[](#writing-to-storage)

```
use Origin\Storage\Storage;
Storage::write('test.txt','hello world!');
```

You can also write to folders directly. Folders in the tree that do not exist will be created automatically.

```
Storage::write('my_folder/test.txt','hello world!');
```

### Reading From Storage

[](#reading-from-storage)

```
use Origin\Storage\Storage;
$contents = Storage::read('my_folder/test.txt');
```

### Deleting From Storage

[](#deleting-from-storage)

To delete files or folders

```
Storage::delete('my_folder/test.txt');
Storage::delete('my_folder');
```

Folders are deleted recursively automatically, when using delete.

### Listing Storage Contents

[](#listing-storage-contents)

> Version 2.0 no longer lists names of files relative to the path you pass to the list method. The full path name is always returned.

To list the files on the storage

```
use Origin\Storage\Storage;
$allFiles = Storage::list();
```

Storage contents are listed recursively and it will provide you with an array of `FileObjects`. Each file has is an object which can be accessed as an array or an object

```
// Will look like this
Origin\Storage\FileObject Object
(
    [name] => bar.txt
    [directory] => folder
    [path] => folder/bar.txt
    [extension] => txt
    [timestamp] => 1601121922
    [size] => 32
)

echo $file->name;
echo $file['name'];
```

When the `FileObject` is converted to a string it will become a path e.g. `/main/subfolder/foo.txt`

If you just want the files of particular folder, then it will list all files recursively under that folder.

```
use Origin\Storage\Storage;
$files = Storage::list('my_folder');
```

### Working with Multiple Storages

[](#working-with-multiple-storages)

Whether you are using multiple storage engines, or you multiple configurations for a single storage engine, the Storage utility is flexible.

You can get the configured Storage volume

```
$volume = Storage::volume('sftp-backup');
$data = $volume->read('transactions.csv');
```

Or you can pass an options array telling the Storage object which configuration to use

```
$data = Storage::read('transactions.csv',[
    'config'=>'sftp-backup'
]);
```

Storage Engines
---------------

[](#storage-engines)

### Local

[](#local)

The local storage simply works with data from the drive.

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\LocalEngine;

Storage::config('default', [
    'className' => LocalEngine::class
    'root' => '/var/www/storage',
    'lock' => true // default
 ]);
```

### FTP

[](#ftp)

Then you need to configure this

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\FtpEngine;

Storage::config('default', [
    'className' => FtpEngine::class
    'engine' => 'Ftp',
    'host' => 'example.com',
    'port' => 21,
    'username' => 'james',
    'password' => 'secret',
    'ssl' => false
 ]);
```

options for configuring FTP include:

- host: the hostname or ip address
- port: the port number. default 21
- username: the ftp username
- password: the ftp password
- timeout: default 10 seconds
- passive: deafult false
- root: the root folder of the storage within your ftp account
- ssl: default: false

### SFTP

[](#sftp)

To use the SFTP engine, you need to install `phpseclib`

```
$ composer require phpseclib/phpseclib:~2.0

```

Then configure as follows:

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\SftpEngine;

Storage::config('default', [
    'className' => SftpEngine::class
    'host' => 'example.com',
    'port' => 22,
    'username' => 'james',
    'password' => 'secret'
 ]);
```

If you use want to use a private key to login, you can either provide the filename with the full path or the contents of the private key itself.

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\SftpEngine;

Storage::config('default', [
    'className' => SftpEngine::class
    'host' => 'example.com',
    'port' => 22,
    'username' => 'james',
    'privateKey' => '/var/www/config/id_rsa'
]);
```

If your private key requires a password then you can provide that as well. See the [How to setup SSH keys ](https://linuxize.com/post/how-to-set-up-ssh-keys-on-ubuntu-1804/) tutorial for more information.

options for configuring SFTP include:

- host: the hostname or ip address
- port: the port number. default 22
- username: the ssh account username
- password: the ssh account password
- timeout: default 10 seconds
- root: the root folder of the storage. e.g. /home/user/sub\_folder
- privateKey: either the private key for the account or the filename where the private key can be loaded from

### S3

[](#s3)

The S3 Engine works with [Amazon S3](https://aws.amazon.com/s3/) and any other object storage server which uses the S3 protocol, for example [minio](https://min.io/).

To use the S3 Engine, you need to install the Amazon AWS SDK

```
$ composer require aws/aws-sdk-php

```

Then you can configure the S3 engine like this

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\S3Engine;

Storage::config('default', [
    'className' => S3Engine::class
    'credentials' => [
        'key' => env('S3_KEY'), // * required
        'secret' => env('S3_SECRET'), // * required
    ],
    'region' => 'us-east-1', // * required
    'version' => 'latest',
    'endpoint' => env('S3_ENDPOINT'), // for S3 comptabile protocols
    'bucket' => env('S3_BUCKET') // * required
 ]);
```

Options for configuring the `S3` engine are:

- credentials: this is required and is an array with both `key` and `secret`
- region: The label for location of the server
- version: version setting
- endpoint: If you are not using Amazon S3. e.g. `http://127.0.0.1:9000`
- bucket: The name of the bucket, this is required and the bucket should exist.

#### Minio Server (S3)

[](#minio-server-s3)

To fire up your own minio server locally you can run the docker command

```
$ docker run -p 9000:9000 minio/minio server /data

```

You can access this also using your web browser at `http://127.0.0.1:9000`.

Zip
---

[](#zip)

To use the ZIP storage engine, provide the filename with a full path.

```
use Origin\Storage\Storage;
use Origin\Storage\Engine\ZipEngine;

Storage::config('default', [
    'className' => ZipEngine::class
    'file' => '/var/www/backup.zip'
]);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~25 days

Total

15

Last Release

1858d ago

Major Versions

1.4.0 → 2.0.02020-09-26

2.0.2 → 3.0.02021-01-04

2.0.3 → 3.1.02021-04-13

PHP version history (3 changes)1.0.0PHP ^7.2.0

2.0.2PHP &gt;=7.2.0

3.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8a821333d9c7b7bc2ad3d164d142f65cd3912dea78033d31f76b0f19ba8a0c?d=identicon)[originphp](/maintainers/originphp)

---

Top Contributors

[![jamielsharief](https://avatars.githubusercontent.com/u/20553479?v=4)](https://github.com/jamielsharief "jamielsharief (72 commits)")

---

Tags

ftps3sftpzipstoragelocaldiskminiooriginPHP

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[innoge/laravel-rclone

A sleek PHP wrapper around rclone with Laravel-style fluent API syntax

174.1k](/packages/innoge-laravel-rclone)[mwguerra/filemanager

A full-featured file manager package for Laravel and Filament v5 with dual operating modes, drag-and-drop uploads, S3/MinIO support, and comprehensive security features.

718.5k1](/packages/mwguerra-filemanager)

PHPackages © 2026

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