jamalosm/config-writer

Config writer

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.0 2019-05-19 16:19 UTC

This package is auto-updated.

Last update: 2022-11-20 00:33:47 UTC


README

Installing

composer require jamalosm/config-writer 1.*

Usage

// config/app.php
return [
    "name" => 'B-ONE Application',
    "versions" => [
        "v1" => "19.02.2017",
        "v2" => "23.04.2018",
    ]
];
<?php
// index.php
require 'vendor/autoload.php';

$configPath = __DIR__."/config";

$instance = \BONE\Config\Config::getInstance($configPath);

$configWriter = new \BONE\ConfigWriter\ConfigWriter($configPath, $instance);

###Methods

write($key, $default = null)

Write configuration value in config file.

    $configWriter->write('app.path', 'app/local'); //'app/local'
    
    $instance->get('app.path'); //'app/local'
    
    $instance->get('app');
    /*
    [
        "name" => 'B-ONE Application',
        "versions" => [
            "v1" => "19.02.2017",
            "v2" => "23.04.2018",
        ],
        "path" => "app/local"
    ]
    */

File before writing.

// config/app.php
return [
    "name" => 'B-ONE Application',
    "versions" => [
        "v1" => "19.02.2017",
        "v2" => "23.04.2018",
    ],
    "path" => "app/local"
];