承接 php-strict/config 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

php-strict/config

Composer 安装命令:

composer require php-strict/config

包简介

Storage and loader for configuration object.

README 文档

README

Software License Build Status codecov Codacy Badge

Storage and loader for configuration object. Allows be initialised with defaults and load saved configuration from PHP, INI, JSON file.

Requirements

  • PHP >= 7.1

Install

Install with Composer:

composer require php-strict/config

Usage

Define your own application configuration class by extending Config class:

use PhpStrict\Config\Config

class AppConfig extends Config
{
    /**
     * Project root
     * 
     * @var string
     */
    public $root = '/';
    
    /**
     * Debug enable|disable
     * 
     * @var bool
     */
    public $debug = false;
    
    /**
     * Database settings
     */
    public $dbServer = '';
    public $dbUser = '';
    public $dbPassword = '';
    public $dbName = '';
    public $dbCharset = '';
    public $dbTablePrefix = ''
    
    /*
     * another configuration fields here
     */
    
}

Example of configuration file content:

DEBUG=true

DB_SERVER=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=testproject
DB_CHARSET=utf8
DB_TABLE_PREFIX=

CACHE=true

Create and fill your configuration object with data from saved configuration file:

$config = new AppConfig();
$config->loadFromFile('config.ini');

Use configuration object fields directly on demand:

mysqli::__construct(
    $config->dbServer, 
    $config->dbUser, 
    $config->dbPassword, 
    $config->dbName
);

Get subconfig by fields prefix:

$dbConfig = $config->getSlice('db');

mysqli::__construct(
    $dbConfig->server, 
    $dbConfig->user, 
    $dbConfig->password, 
    $dbConfig->name
);

Tests

To execute the test suite, you'll need Codeception.

vendor\bin\codecept run

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固