artox-lab/json-config

该软件包最新版本(1.5.1)没有提供许可证信息。

PHP的又一JSON配置工具

1.5.1 2021-01-19 15:56 UTC

This package is not auto-updated.

Last update: 2024-09-25 09:35:07 UTC


README

通过Composer安装

{
    "require": {
        "artox-lab/json-config": "1.3.1"
    }
}

运行 composer update

配置定义

config.json

{
  "name": "Suppa Project",
  "version": 1,
  "rating": 2.5,
  "authors": [
    "code.god@gmail.com"
  ],
  "emails": {
    "subscription": [
      "user1@gmail.com",
      "user2@gmail.com"
    ],
    "user": {
      "name": "Johny"
    },
    "should_notify": true
  }
}

配置使用

index.php

<?php

include 'vendor/autoload.php';

// Setup path to config file
JsonConfig\Config::setup('config.json');

// Get data from config
$subscriptions = JsonConfig\Config::get('emails.subscription');