Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-16T20:40:09.000Z (almost 3 years ago)
- Last Synced: 2024-08-09T23:25:17.874Z (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
[![Build Status](https://app.travis-ci.com/quillstack/local-storage.svg?branch=main)](https://app.travis-ci.com/quillstack/local-storage)
[![Downloads](https://img.shields.io/packagist/dt/quillstack/local-storage.svg)](https://packagist.org/packages/quillstack/local-storage)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=quillstack_local-storage&metric=coverage)](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=quillstack_local-storage&metric=ncloc)](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[![StyleCI](https://github.styleci.io/repos/394779968/shield?branch=main)](https://github.styleci.io/repos/394779968?branch=main)
[![CodeFactor](https://www.codefactor.io/repository/github/quillstack/local-storage/badge)](https://www.codefactor.io/repository/github/quillstack/local-storage)
![Packagist License](https://img.shields.io/packagist/l/quillstack/local-storage)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=quillstack_local-storage&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
[![Maintainability](https://api.codeclimate.com/v1/badges/d3fbd09f1580534b0c0e/maintainability)](https://codeclimate.com/github/quillstack/local-storage/maintainability)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=quillstack_local-storage&metric=security_rating)](https://sonarcloud.io/dashboard?id=quillstack_local-storage)
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/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
```