动态的 key:value JSON 配置文件

v0.5.9 2022-03-10 23:21 UTC

This package is auto-updated.

Last update: 2024-09-11 05:01:55 UTC


README

Laravel 配置包

安装

  1. 如何安装
composer require miladimos/conf
  1. 打开 conf/app.php 并将以下内容添加到 providers 数组中
Miladimos\Conf\Providers\ConfServiceProvider::class,
  1. 运行以下命令来安装包
php artisan conf:install

辅助函数

conf('key') // 返回配置的值

服务

use Miladimos\Conf\Services\ConfigJsonService;

ConfigJsonService::all(); // return all stored configs in config.json file
ConfigJsonService::show($id); // receive id of config and return one config
ConfigJsonService::store($date); 
ConfigJsonService::update($date, $id); 
ConfigJsonService::delete($id); // receive id of config and  delete

路由

GET  api/version/conf/all          -> name: conf.all // return all configs
GET  api/version/conf/show/{id}    -> name: conf.show // return single config
POST api/version/conf/update/{id}  -> name: conf.update // update
POST api/version/conf/store        -> name: conf.store // store
GET  api/version/conf/delete/{id}  -> name: conf.delete // delete

更新和存储会接收这些数据

[
    'key' => 'yourkey',
    'value' => 'yourvalue',
    'description' => 'description',
]

然后给 config.json 文件读写权限,或者更改文件所有者为当前用户

sudo chown -R $USER config.json