PHP code example of painlesscode / laravel-dynamic-config

1. Go to this page and download the library: Download painlesscode/laravel-dynamic-config 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/ */

    

painlesscode / laravel-dynamic-config example snippets


# /config/dynamic_config.php 
return [
    'dynamic_configs' => [
        'mail',
    ],
];

echo config('mail.default'); 
// Will return the value of dynamic mail.default (if mail is already added to dynamic_configs array);

echo config('defailt.mail.default'); 
// Will return the value of original configuration (if default_prefix is set to 'default');

config('mail.default', 'array'); 
// It is like default laravel config set. it will be set but persists in only current request.

// to set value permanently
use Painless\DynamicConfig\Facades\DynamicConfig; 

// or you can use DynamicConfig Alias

DynamicConfig::set('mail.default', 'ses'); 
// It will save the value and persist it in database and cache (if enabled)

use Painless\DynamicConfig\Facades\DynamicConfig; 
// or you can use DynamicConfig Alias

DynamicConfig::revert('mail.default', 'ses'); 
// It will revert the config value to its original state and persist it. 
 bash
php artisan vendor:publish --provider="Painless\DynamicConfig\DynamicConfigServiceProvider"