The package to manage files on the local storage.
To install this package, run the standard command using Composer:
composer require quillstack/local-storage
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');
}
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.
Run tests using a command:
phpdbg -qrr ./vendor/bin/unit-tests
$ docker-compose up -d
$ docker exec -w /var/www/html -it quillstack_local-storage sh