combindma / laravel-option
用于 Laravel 的键值存储
0.0.1
2024-07-29 16:36 UTC
Requires
- php: ^8.3
- illuminate/contracts: ^11.0
- spatie/laravel-package-tools: ^1.16
- spatie/valuestore: ^1.3
Requires (Dev)
- larastan/larastan: ^2.9.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0.0
- orchestra/testbench: ^9.0.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
此包在内部使用 spatie valuestore。
关于 Combind Agency
Combine Agency 是一家领先的网页开发公司,专注于使用现代技术构建创新和高性能的网页应用程序。我们的经验丰富的开发人员、设计师和项目经理致力于提供针对客户独特需求的优质服务。
如果您需要帮助您的下一个项目或想讨论定制解决方案,请随时 联系我们 或访问我们的 网站 了解我们的服务更多信息。让我们一起创造一些令人惊叹的东西!
安装
您可以通过 composer 安装此包
composer require combindma/laravel-option
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="laravel-option-config"
这是发布配置文件的内容
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', ];
用法
此包可以轻松存储和检索一些散乱的值。存储的值以 json 文件保存。
它可以这样使用
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
测试
composer test
更新日志
有关最近更改的更多信息,请参阅 更新日志。
贡献
请参阅 贡献指南 以获取详细信息。
安全漏洞
请参阅我们如何报告安全漏洞的 安全策略。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。