PHP code example of cupoftea / easycfg

1. Go to this page and download the library: Download cupoftea/easycfg library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cupoftea / easycfg example snippets


// Global data
Cfg::set('key', 'value');
$value = Cfg::get('key');

// Class data
cfg()->set('key', 'value', MyConfigurableCommand::class);
$value = cfg('key', MyConfigurableCommand::class);

// Object data (Class instance)
// where $myobject = {"id": 1, "property": "value"}
cfg()->set('key', 'value', $myObject);
cfg()->set('foo', 'bar', MyConfigurableClass::class, $myObject->id);
$cfg = cfg()->all($myObject);


// Settings in Blade partials

// app.blade.php
<div class="content @cfg('scheme')-scheme">
    @yield('content')
</div>

// page.blade.php
@cfg('scheme', 'dark')
@section('content')
    ...
@endsection

// Rendered HTML
<div class="content dark-scheme">
    ...
</div>