Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/unclexo/filestorage

:rocket: A blazing fast and light-weight flat-file storage designed for storing array data to keys
https://github.com/unclexo/filestorage

associative-array-storage file-storage flat-file-storage storage storage-container storage-manager

Last synced: 11 days ago
JSON representation

:rocket: A blazing fast and light-weight flat-file storage designed for storing array data to keys

Awesome Lists containing this project

README

        

# filestorage
A blazing fast and light-weight flat-file storage designed for storing array data to keys.

[![PHP Version](https://img.shields.io/badge/php-%3E%3D7.3-informational)](https://php.net/)
[![PHPStan](https://img.shields.io/badge/PHPStan-passing-success)](https://phpstan.org/)
[![PHP Unittest](https://img.shields.io/badge/tests-15-blue)](https://packagist.org/packages/phpunit/phpunit)
[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Funclexo%2Ffilestorage)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Funclexo%2Ffilestorage)

## Sample Array Data

```php
[
'clientId' => 'facebookClientId',
'clientSecret' => 'facebookClientSecret',
'redirectUri' => 'facebookRedirectUri',
],
'twitter' => [
'clientId' => 'twitterClientId',
'clientSecret' => 'twitterClientSecret',
'redirectUri' => 'twitterRedirectUri',
],
];
```

Alternatively, you can store (key => value) pairs too.

```php
'value',
'more_key' => ['key' => 'value'],
];
```

## Download using composer

```bash
composer require unclexo/filestorage
```

## Creating a store
`filestorage` stores array data into a file. You can create a file-storage using `Storage::create($data, $location)`.
Keep in mind `$location` must be existed and writable.

```php
[
'clientId' => 'facebookClientId',
'clientSecret' => 'facebookClientSecret',
'redirectUri' => 'facebookRedirectUri',
],
'twitter' => [
'clientId' => 'twitterClientId',
'clientSecret' => 'twitterClientSecret',
'redirectUri' => 'twitterRedirectUri',
],
];

/** File must be writable */
$location = '/home/username/data/storage.txt';

Storage::create($data, $location);
```

## Using the store
Once you've created a store, you can use the store through the whole application. Just create an instance of the store specifying the file location and use wherever you need it.

```php
'facebookClientId',
'clientSecret' => 'facebookClientSecret',
'redirectUri => 'facebookRedirectUri',
]
```

#### To set data
```php