Download the PHP package websolutionfalcon/laravel-simple-cold-storage without Composer
On this page you can find all versions of the php package websolutionfalcon/laravel-simple-cold-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download websolutionfalcon/laravel-simple-cold-storage
More information about websolutionfalcon/laravel-simple-cold-storage
Files in websolutionfalcon/laravel-simple-cold-storage
Package laravel-simple-cold-storage
Short Description A simple, extensible Laravel package for storing data using filesystem with type-safe StorageKey DTOs
License MIT
Homepage https://github.com/websolutionfalcon/laravel-simple-cold-storage
Informations about the package laravel-simple-cold-storage
Laravel Simple Cold Storage
A simple, extensible Laravel package for storing data to the local filesystem using a clean, type-safe API with StorageKey DTOs.
Features
- Dead simple: One main class, minimal configuration
- Easily extensible: Create custom encoders and storage implementations
- Type-safe API: Modern PHP 8.2+ with readonly properties
- StorageKey DTO: Powered by Spatie Laravel Data with validation attributes
- Laravel Storage: Works with any Laravel filesystem disk (local, s3, ftp, etc.)
- Configurable prefix: Customize storage paths
- JSON encoding: Built-in JSON encoder, add your own encoders easily
Installation
Publish the configuration file (optional):
Quick Start
Configuration
config/laravel-simple-cold-storage.php:
The package uses Laravel's Storage facade, so you can use any disk configured in config/filesystems.php:
local- Local filesystem (default)s3- Amazon S3ftp- FTP serversftp- SFTP server- Or any custom disk you configure
Files are stored at: {disk}/{prefix}/{type}/{identifier}[.{variant}].json
Using Different Storage Disks
Simply change the disk in your config or .env:
Files will be stored at: {disk}/{prefix}/{type}/{identifier}[.{variant}].json
Example:
- Disk:
s3, Prefix:archives→s3://bucket/archives/orders/12345.json - Disk:
local, Prefix:cold-storage→storage/app/cold-storage/orders/12345.json
Extending with Custom Encoders
1. Create Your Encoder
Create a custom encoder in your Laravel application:
2. Configure Your Encoder
Update your published config file:
That's it! The package will now use your custom encoder.
Extending with Custom Storage
Example: MySQL Storage
Create a custom storage implementation for MySQL:
Configure Your Custom Storage
Just update the config:
The fromSettings() method lets each storage implementation define its own configuration needs!
Use Cases
Archive Old Data
Versioned Backups
Session Data
StorageKey
The StorageKey DTO identifies stored data:
File Structure
Dependency Injection
Example: Custom MySQL Storage
Here's a complete example of creating a MySQL storage implementation:
Then configure it:
Testing
Run the package tests:
Run with coverage:
Architecture
The package provides:
- Contracts:
ColdStorageInterface,EncoderInterface - Default Storage:
ColdStorage(local filesystem) - Default Encoder:
JsonEncoder - DTO:
StorageKeyfor type-safe keys - Exceptions: Custom exceptions for error handling
You extend by:
- Create a class implementing
ColdStorageInterfaceorEncoderInterface - Configure it in
config/laravel-simple-cold-storage.php - Done - the package will use your implementation
Error Handling
Changelog
Please see CHANGELOG for recent changes.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security issues, please email [email protected].
Credits
- Slava Mehovich
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-simple-cold-storage with dependencies
illuminate/collections Version ^12.0
illuminate/support Version ^12.0
spatie/laravel-data Version ^4.19