PHP code example of danielefavi / laravel-settings

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

    

danielefavi / laravel-settings example snippets


settings()->set('code_langs', ['php', 'javascript', 'python']);

// this does the same of the previous line of code
app('settings')->set('max_connection', 100);

$codeLangs = settings()->get('code_langs');
// codeLangs = Array( [0] => php [1] => javascript [2] => python )

$maxConn = settings()->get('max_connection');

// if the setting max_connection is not found then it returns 999
$maxConn = settings()->get('max_connection', 999);

settings()->set('counter', 10); // the counter is 10

settings()->inc('counter'); // incrementing the counter by 1, so the counter is 11
settings()->inc('counter'); // incrementing the counter by 1, so the counter is 12
settings()->inc('counter', 3); // incrementing the counter by 3, so the counter is 15

$counter = settings()->get('counter'); // counter == 15

settings()->set('counter', 10); // the counter is 10

settings()->dec('counter'); // decrementing the counter by 1, so the counter is 9
settings()->dec('counter', 4); // decrementing the counter by 5, so the counter is 5

$counter = settings()->get('counter'); // counter == 5

settings()->attach('tags', ['tag-1', 'tag-2']); // attaching (or creating) the array
settings()->attach('tags', ['tag-3', 'tag-4']); // attaching an array to the array
settings()->attach('tags', 'tag-5'); // attaching a value to the array

$tags = settings()->get('tags');
// tags contains tag-1, tag-2, tag-3, tag-4, tag-5

settings()->set('names', 'John');
settings()->attach('names', ',Doe,Wan');
settings()->attach('names', ',Clare');

$names = settings()->get('names'); // John,Doe,Wan,Clare