Laravel Storage with Database is a powerful package that provides a seamless way to store and retrieve text-based data using a database in Laravel. It offers a simple and intuitive API similar to Laravel's built-in Storage facade, making it easy to switch from file-based storage to database storage for your text-based data.
- Store and retrieve text-based data using a database
- Seamless integration with Laravel's Storage facade
- Simple and intuitive API for interacting with stored data
- Supports various database drivers (MySQL, PostgreSQL, SQLite, etc.)
- Customizable database table and column names
- Provides mock implementations for file-related functions
- Comprehensive documentation and code examples
You can install the package via Composer:
composer require rakshitbharat/laravel-storage-with-database
After installing the package, you need to publish the configuration file:
php artisan vendor:publish --provider="Rakshitbharat\LaravelStorageWithDatabase\StorageDatabaseServiceProvider" --tag="config"
This will create a storage-database.php
configuration file in your config
directory. You can modify this file to customize the database connection, table name, and column names.
Next, run the database migration to create the necessary table:
php artisan migrate
Once the package is installed and configured, you can start using it to store and retrieve text-based data. The package provides a StorageDatabase
facade that you can use to interact with the stored data.
To store data, you can use the put
method:
use Rakshitbharat\LaravelStorageWithDatabase\Facades\StorageDatabase;
StorageDatabase::put('key', 'value');
To retrieve data, you can use the get
method:
use Rakshitbharat\LaravelStorageWithDatabase\Facades\StorageDatabase;
$value = StorageDatabase::get('key');
To check if a key exists, you can use the exists
method:
use Rakshitbharat\LaravelStorageWithDatabase\Facades\StorageDatabase;
$exists = StorageDatabase::exists('key');
To delete data, you can use the delete
method:
use Rakshitbharat\LaravelStorageWithDatabase\Facades\StorageDatabase;
StorageDatabase::delete('key');
The package provides several other methods for interacting with the stored data, such as append
, prepend
, copy
, move
, size
, lastModified
, and more. Please refer to the documentation for a complete list of available methods.
The package comes with a configuration file storage-database.php
that allows you to customize various settings. You can modify the database connection, table name, and column names to suit your requirements.
For detailed documentation and code examples, please refer to the official documentation.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
Laravel Storage with Database is open-sourced software licensed under the MIT license.