alisaleem/laravel-settings
最新稳定版本:v1.2.2
Composer 安装命令:
composer require alisaleem/laravel-settings
包简介
File based configurable settings for laravel applications
关键字:
README 文档
README
Store your application settings in any of your applications storage filesystems. The schema for the settings is defined by a normal PHP class and all primitive types are supported. This also provides IDE type hints when reading to writing settings.
Updated values are written to the filesystem on destruct.
Installation
You can install the package via composer:
composer require alisaleem/laravel-settings
Create your own Settings class and extend the abstract Settings class from this package
namespace App; class MySettings extends \AliSaleem\LaravelSettings\BaseSettings { public string $key; public string $anotherKey = 'Default Value'; }
Optionally add the helper function. This will also provide IDE type-hinting
if (! function_exists('settings')) { function settings(): \App\MySettings { return resolve(config('settings.class')); } }
You can publish the config file with:
php artisan vendor:publish --tag="settings-config"
Set the class and storage location in the config file
return [ 'class' => \App\MySettings::class, 'storage' => [ 'disk' => null, 'path' => 'settings.json', ], ];
Usage
// To retrieve a value $value = resolve(\App\MySettings::class)->key; $value = settings()->anotherKey; // To set a value resolve(\App\MySettings::class)->key = 'changed'; settings()->anotherKey = 'changed';
Testing
composer test
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.
统计信息
- 总下载量: 544
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-08