Search by

solophp / storage

Vitaliy Olos

This package is abandoned and no longer maintained. No replacement package was suggested.

Simple file-based storage system for storing string data using key-value pairs.

Package info

github.com/SoloPHP/Storage

pkg:composer/solophp/storage

Statistics

Installs: 100

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.2.0 2025-08-03 10:19 UTC

This package is auto-updated.

Last update: 2026-10-28 19:39:08 UTC


README

Warning

Abandoned. This package is no longer maintained and gets no fixes. It has no successor and stays on Packagist for the projects that use it. The current Solo packages are listed at solophp.github.io.

Latest Version on Packagist License PHP Version

A lightweight, file-based storage system for PHP applications that provides simple key-value pair storage functionality.

Features

  • Simple key-value storage interface
  • File-based persistence
  • Thread-safe file operations
  • Directory traversal protection
  • Minimal dependencies
  • Type-safe implementation (strict types)

Requirements

  • PHP 8.1 or higher

Installation

composer require solophp/storage

Usage

Basic Setup

use Solo\Storage;

// Initialize with default storage location (current directory)
$storage = new Storage();

// Or specify a custom storage directory
$storage = new Storage('/path/to/storage/directory');

Store Data

// Store a string value
$storage->set('user.name', 'John Doe');
$storage->set('user.email', 'john@example.com');

Retrieve Data

// Get a stored value
$name = $storage->get('user.name'); // Returns 'John Doe'

// Handle non-existent keys
$value = $storage->get('non.existent.key'); // Returns null

Check Data Existence

// Check if a key exists
if ($storage->has('user.name')) {
    // Key exists
}

Delete Data

// Delete a stored value
$storage->delete('user.name');

Error Handling

All methods are designed to fail gracefully:

  • set() returns bool indicating success/failure
  • get() returns null if key doesn't exist or on error
  • has() returns bool indicating key existence
  • delete() returns bool indicating success/failure

Security

The storage system includes protection against directory traversal attacks by sanitizing storage keys.

Thread Safety

File operations use exclusive locks (LOCK_EX) to ensure thread safety when writing data.

License

MIT