PHP code example of danielrhodeswarp / kimino-config
1. Go to this page and download the library: Download danielrhodeswarp/kimino-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/ */
danielrhodeswarp / kimino-config example snippets
//this is YourProject/database/seeds/SeedMyKiminos.php
use Illuminate\Database\Seeder;
use Danielrhodeswarp\KiminoConfig\KiminoConfig;
class SeedMyKiminos extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//some settings that we want
$settings = [
'sitebot_hometown' => [
'value' => 'Parts Unknown',
'valid_values' => null,
'user_hint' => 'Where should we say that Sitebot comes from?'
],
'sitebot_temperament' => [
'value' => 'cranky',
'valid_values' => 'cranky,irritable,curmudgeonly,peevish,churlish',
'user_hint' => 'What sort of mood is Sitebot in?'
],
//etc
];
//loop through and add to DB (via Eloquent)
foreach ($settings as $name => $setting) {
$config = new KiminoConfig();
$config->setting = $name;
$config->value = $setting['value'];
$config->valid_values = $setting['valid_values'];
$config->user_hint = $setting['user_hint'];
$config->save();
}
}
}
//this is a controller, model, command etc in your project
use Danielrhodeswarp\KiminoConfig\KiminoConfig;
.
.
.
$settingValue = KiminoConfig::getSetting('very_important_setting');
if(is_null($settingValue))
{
abort(500, 'Bad things have happened');
}
veryImportantThing($settingValue);
//this is a controller, model, command etc in your project
use Danielrhodeswarp\KiminoConfig\KiminoConfig;
.
.
.
class SomeClassInYourProject
{
//configure auth method based on saved setting
public function handleSomethingAuthMethod()
{
$authMethod = KiminoConfig::getSetting('something_auth_method');
//call appropriate method based on setting value
$this->{"setSomethingAuthMethod_{$authMethod}"}();
}
//set auth method to BASIC
private function setSomethingAuthMethod_basic()
{
fancyThingToSetBasicAuth();
}
//set auth method to DIGEST
private function setSomethingAuthMethod_digest()
{
CoolStuffToSetDigestAuth();
}
}
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.