ssntpl / cloud-storage
Laravel Storage Driver to sync files on to the multiple disks asynchronously
Requires
- php: ^7.4|^8.0
- laravel/framework: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.17
- nunomaduro/collision: ^6.0
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- dev-main
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-feature/added_mimetype_functionality
- dev-bug/misc43_handle_cache_disk
- dev-bugfix/shouldbeunique_issue_with_config_issue_handling
- dev-feature/files_function_change
- dev-feature/misc39_cache_disk_priority
- dev-feature/return_url
- dev-feature/wb6385_optimize_some_action_on_files
- dev-feature/wb6385_delete_file_by_jobs
- dev-feature/wb6385_optimize_code_and_flow
This package is auto-updated.
Last update: 2025-09-05 12:51:19 UTC
README
A powerful Laravel storage driver that enables seamless synchronization of files across multiple disks.
Features
- Multi-Disk Support: Define multiple remote disks to store your files.
- Asynchronous Sync: Files are synced to all remote disks asynchronously, ensuring high availability.
- Optimized Access: Files are accessed from the readable disks priority wise.
Installation
Install the package via Composer:
composer require ssntpl/cloud-storage
Usage
-
Configuration: In your Laravel application's
config/filesystems.php
, define your disks.'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app/private'), 'write_enabled' => true, 'write_priority' => 2, 'read_priority' => 1, 'retention' => 1, ], 'cloud_disk' => [ 'driver' => 'cloud', 'disks' => [ 'local', // just write here disk name and other configuration variable can be set on this disk configuration array as mention above. [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', 'write_enabled' => true, // false means read only opertions should be done. default is true 'write_priority' => 1, // 0 means least priority. default is 0 'read_priority' => 2, // 0 means least priority. default is 0 'retention' => 0, // in days, 0 means no retention. default is 0. if retention is greater than 0, make sure your queue connection sould not be sync. ], ], ], // Define other disks (remote disks used in the cloud disk above) ],
-
Upload Files: When uploading files using this driver, they will first be stored on the cache disk and then asynchronously synced to all defined remote disks.
Storage::disk('cloud_disk')->put('path/to/file.jpg', $fileContents);
-
Access Files: The driver will check the read disks priority wise.
$file = Storage::disk('cloud_disk')->get('path/to/file.jpg');
Future Enhancements
- Improved Sync Strategies: Additional options for sync strategies, such as prioritizing certain disks.
- Monitoring and Alerts: Integrate monitoring for sync failures and performance metrics.
Changelog
Please see CHANGELOG for detailed information on the latest changes.
Security Vulnerabilities
If you discover any security-related issues, please email support@ssntpl.com instead of using the issue tracker.
Credits
License
This package is licensed under the MIT License. See the License File for more details.