https://github.com/quillstack/local-storage
The library to manage files in local storage.
https://github.com/quillstack/local-storage
local php8 quillstack storage
Last synced: 4 months ago
JSON representation
The library to manage files in local storage.
- Host: GitHub
- URL: https://github.com/quillstack/local-storage
- Owner: quillstack
- License: mit
- Created: 2021-08-10T20:59:32.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-16T20:40:09.000Z (over 3 years ago)
- Last Synced: 2025-02-18T20:23:34.453Z (5 months ago)
- Topics: local, php8, quillstack, storage
- Language: PHP
- Homepage: https://quillstack.org/storage
- Size: 27.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Quillstack Local Storage
[](https://app.travis-ci.com/quillstack/local-storage)
[](https://packagist.org/packages/quillstack/local-storage)
[](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[](https://github.styleci.io/repos/394779968?branch=main)
[](https://www.codefactor.io/repository/github/quillstack/local-storage)

[](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[](https://codeclimate.com/github/quillstack/local-storage/maintainability)
[](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
The package to manage files on the local storage.
### Installation
To install this package, run the standard command using _Composer_:
```
composer require quillstack/local-storage
```### Usage
Create a class or inject it as a dependency:
```php
use Quillstack\LocalStorage\LocalStorage;$storage = new LocalStorage();
$storage->save('var/cache/token.txt', 'muHaloosPps23sKkdsaaBBcei');
```If you want to use it as a dependency:
```php
use Quillstack\LocalStorage\LocalStorage;public function __construct(private LocalStorage $storage)
{
//
}public function getTokenFromCache()
{
$this->storage->get('var/cache/token.txt');
}
```### Storage interface
This package implements `quillstack/storage-interface`: \
https://github.com/quillstack/storage-interface \
with methods:- `get()` Retrieves the contents of a file. \
This method opens a file and return its contents, it throws an exception if file doesn't exist.
- `exists()` Checks if the file exists on the storage.
- `missing()` Checks if the file is missing from the storage.
- `save()` Saves the contents to the file. \
This method throws an exception if there are any troubles with saving a file (e.g. no space left on device).
- `delete()` Deletes one or more files. \
This method deletes one or many files and throws an exception if error occurs during deleting a file.### Unit tests
Run tests using a command:
```
phpdbg -qrr ./vendor/bin/unit-tests
```### Docker
```shell
$ docker-compose up -d
$ docker exec -w /var/www/html -it quillstack_local-storage sh
```