combindma/laravel-option
最新稳定版本:0.2.0
Composer 安装命令:
composer require combindma/laravel-option
包简介
A key-value storage for laravel
README 文档
README
This package uses spatie valuestore under the hood.
About Combind Agency
Combine Agency is a leading web development agency specializing in building innovative and high-performance web applications using modern technologies. Our experienced team of developers, designers, and project managers is dedicated to providing top-notch services tailored to the unique needs of our clients.
If you need assistance with your next project or would like to discuss a custom solution, please feel free to contact us or visit our website for more information about our services. Let's build something amazing together!
Installation
You can install the package via composer:
composer require combindma/laravel-option
You can publish the config file with:
php artisan vendor:publish --tag="laravel-option-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Default disk |-------------------------------------------------------------------------- | | This is the default disk that will be used to store the options file. | */ 'disk' => 'local', /* |-------------------------------------------------------------------------- | Default filename |-------------------------------------------------------------------------- | | This is the default filename for the options file. | */ 'filename' => 'options.json', ];
Usage
This package makes it easy to store and retrieve some loose values. Stored values are saved as a json file.
It can be used like this:
option()->put('key', 'value'); option()->get('key'); // Returns 'value' option()->has('key'); // Returns true // Specify a default value for when the specified key does not exist option()->get('non existing key', 'default') // Returns 'default' option()->put('anotherKey', 'anotherValue'); // Put multiple items in one go option()->put(['ringo' => 'drums', 'paul' => 'bass']); option()->all(); // Returns an array with all items option()->forget('key'); // Removes the item option()->flush(); // Empty the entire options option()->flushStartingWith('somekey'); // remove all items whose keys start with "somekey" option()->increment('number'); // option()->get('number') will return 1 option()->increment('number'); // option()->get('number') will return 2 option()->increment('number', 3); // option()->get('number') will return 5 // Option implements ArrayAccess option()['key'] = 'value'; option()['key']; // Returns 'value' isset(option()['key']); // Return true unset(option()['key']); // Equivalent to removing the value
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 219
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-29