assertis/config-lib 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

assertis/config-lib

最新稳定版本:4.7.0

Composer 安装命令:

composer require assertis/config-lib

包简介

Simple configuration library

README 文档

README

Design

Configuration library enables you to load configurations into application from different source, it give you way to validate configuration on developer environment.

We are providing 5 base type of configurations.

  • Assertis\Configuration\Drivers\SourceDriver : simple driver, you can set array with configuration into constructor.

  • Assertis\Configuration\Drivers\DatabaseDriver : driver is using PDO connection to gain access to configuration from database. This driver is returning LazyConfiguration.

  • Assertis\Configuration\Drivers\File\IniDriver : configuration provided from .ini file

  • Assertis\Configuration\Drivers\File\JsonDriver : configuration provided from .json file

  • Assertis\Configuration\Drivers\File\PhpDriver : configuration provided from .php file. File should return array

  • Assertis\Configuration\Drivers\File\YmlDriver : configuration provided from .yml file. File should return array

  • Assertis\Configuration\Drivers\File\XmlDriver : configuration provided from .xml file. File should return array with configuration. Ex:

<?php
  return [
    'key' => 'value'
  ];
 ?>

We are returning configuration in 2 type of objects:

  • Assertis\Configuration\Collection\ConfigurationArray is array type object with some extra methods. More detail below.

  • Assertis\Configuration\Collection\LazyConfiguration is simple array type object but with many limitations. Basically you can only use get method, others will throw Exception.

Library is also providing Assertis\Configuration\ConfigurationFactory to create configuration easily.

Extras

  • Configuration will load "common" file if exists. File extension depends of driver type. If we are using IniDriver for test env then common.ini will be loaded if exists.

  • Environment is read from $_SERVER['ENV'] or getenv('ENV')

  • When environment is default (dev) or test, configuration structure will be tested

  • You can get value using path, for example: rdis.db.user

  • When you are asking for key when value is array, this value will be changed to Assertis\Configuration\Collection\ConfigurationArray

  • You can add easily extra drivers

Installation

To install this library add the following to your composer.json file and run composer update:

  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/assertis/config-lib"
    }
  ],
  "require": {
    "assertis/config-lib": "dev-master"
  }

Usage

To use this library add the following to your Silex application:

$app->register(new ConfigurationProvider(), [
    'config.driver' => new IniDriver($app['dir.root'] . '/configs'),
    'config.validator' => $app['validator'],
    'config.validator.constraints' => null
]);

Add new tenant to configuration

  1. First of all your service should have something called tenant schema.
  2. Put your regular tenant body into config/schema/tenant.json e.g.
{
  "database": {
    "order": {
      "dsn": "mysql:host=127.0.0.1;dbname=",
      "username": "root",
      "password": ""
    }
  },
  "nlc": "",
  "barcode_key": "",
  "issuer_id": ""
}
  1. Now in your service you should be able to add tenant to specific config file
php vendor/assertis/config-lib/src/Scripts/AddTenant.php {tenantName} {configFileName}  [tenantSchemaFile]

If tenantSchemaFile is in different localization than config/schema/tenant.json please provide it as a last parameter. E.g. of usage

php vendor/assertis/config-lib/src/Scripts/AddTenant.php hex-qa-b2b stage.json

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固