setbased/typed-config 问题修复 & 功能扩展

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

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

setbased/typed-config

最新稳定版本:2.1.0

Composer 安装命令:

composer require setbased/typed-config

包简介

A lightweight and strong typed that supports PHP, INI, XML, JSON, and YAML files

README 文档

README

A lightweight and strong typed configuration file loader that supports PHP, INI, XML, JSON, and YAML files.

This package is a wrapper around hassankhan/config.

Social Legal Release Tests
Gitter License Latest Stable Version
Build Status
Code Coverage

Manual

Instantiating Strong Typed Config

Creating an instance of Strong Typed Config requires passing an instance of Noodlehaus\Config:

use Noodlehaus\Config;
use SetBased\Config\TypedConfig;

$config = new TypedConfig(new Config('config.json'));

Getting the value of a key

There are two flavors of methods for getting a configuration value:

  • Mandatory keys (man for short). These methods will never return a null value.
  • Optional keys (opt for short). These methods will return null if the key does not exists or has value null.

All methods will try to cast the value of a key to the required type using package setbased/helper-cast. I.e. if the value of key is string(1) method getManBool will return bool(true) and method getManInt will return int(1).

All methods have two arguments:

  1. The key.
  2. An optional default value. this value will be returned if the key does not exists or has value null.

The table below gives an overview of all methods for getting the value of a key.

Method Null Value Return Type
getManArray throws an exception array
getManBool throws an exception bool
getManFiniteFloat throws an exception float
getManFloat throws an exception float
getManInt throws an exception int
getManString throws an exception string
getOptArray returns null array|null
getOptBool returns null bool|null
getOptFiniteFloat returns null float|null
getOptFloat returns null float|null
getOptInt returns null int|null
getOptString returns null string|null

Installation

Strong Typed Config can be installed using composer:

composer require setbased/typed-config

License

This project is licensed under the terms of the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固