sepiphy/config

A tool to quickly parse config from php or yml files.

v1.0.0 2021-03-31 07:04 UTC

This package is auto-updated.

Last update: 2021-03-31 07:05:02 UTC


README

Tests Packagist Packagist Version GitHub

Installation

Install sepiphy/config package via composer.

$ composer require sepiphy/config

Usage

Create a directory called config that contains a few php or yml files (each php file must return an array).

// config/app.php
return [
    'name' => 'sepiphy/config',
    'version' => 'v1.0.0',
];
# config/database.yml
default: sqlite
connections:
    sqlite:
        driver: 'sqlite'
        database: ':memory:'

Load files from the config directory.

<?php

require '/path/to/vendor/autoload.php';

$config = Sepiphy\Config\Config::withDir('/path/to/config')

$config->get('app.name'); // 'sepiphy/config'
$config->get('app.version'); // 'v1.0.0'
$config->get('database.default'); // 'sqlite'
$config->get('database.connections.sqlite'); // ['driver' => 'sqlite', 'database' => ':memory:']