定制 jsl/config 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jsl/config

最新稳定版本:1.0.0

Composer 安装命令:

composer require jsl/config

包简介

Small convenient config library

README 文档

README

Config files

Config files can either be PHP files or JSON files.

Example of a PHP file;

<?php

return [
    'foo' => [
        'bar' => 'FooBar',
    ]
];

Example of a JSON file;

{
    "foo": {
        "bar": "FooBar"
    }
}

Quick example

// Load composers autoloader
require __DIR__ '/path/to/vendor/autoload.php';

// Import and instantiate the config library
use Jsl\Config\Config;

// Load config files through the constructor
$config = new Config([
    __DIR__ . '/config1.php',
    __DIR__ . '/config2.php',
]);

// Load config files after instantiation
$config->load([
    __DIR__ . '/config3.php',
    __DIR__ . '/config4.php',
]);

// If there are duplicate keys, by default, the last loaded will be used 
// (by the order you add them). This is helpful if you have a default config 
// you want to override on different environments.
// If you want existing values to be immutable, you can pass the 
// Config::IGNORE_DUPLICATES flag on instantiation

$config = new Config([...], null, Config::IGNORE_DUPLICATES);

Get a value

// Get a value with a fallback (optional and defaults to NULL)
$foo = $config->get('the-key', 'fallback-value-if-key-not-found');

// Get a value from a multidimentional array.
// Example config: 
// [
//     'foo' => [
//         'bar' => 'FooBar'
//     ]
// ]    

// As default, you can use dot notation for nested keys
$bar = $config->get('foo.bar', 'some-fallback');

// If you want to change the separator to something else, you can 
// either set a new default for the instance through the constructor.
// Using slash (/) instead
$config = new Config([...], '/');

// Or use an alternative for one single get by passing it as the 3rd argument
$config->get('foo/bar', 'fallback', '/');

统计信息

  • 总下载量: 103
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固