quillstack / local-storage
The library to manage files in local storage.
v0.1.0
2022-01-16 20:38 UTC
Requires
- php: ^8.0
- quillstack/storage-interface: ^0.1.0
Requires (Dev)
- quillstack/unit-tests: ^0.2.4
This package is auto-updated.
Last update: 2024-12-17 03:04:36 UTC
README
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:
use Quillstack\LocalStorage\LocalStorage; $storage = new LocalStorage(); $storage->save('var/cache/token.txt', 'muHaloosPps23sKkdsaaBBcei');
If you want to use it as a dependency:
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
$ docker-compose up -d
$ docker exec -w /var/www/html -it quillstack_local-storage sh