PHP code example of combindma / laravel-option

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

    

combindma / laravel-option example snippets


return [
    /*
    |--------------------------------------------------------------------------
    | Default disk
    |--------------------------------------------------------------------------
    |
    | This is the default disk that will be used to store the options file.
    |
    */

    'disk' => 'local',
    /*
    |--------------------------------------------------------------------------
    | Default filename
    |--------------------------------------------------------------------------
    |
    | This is the default filename for the options file.
    |
    */

    'filename' => 'options.json',
];

option()->put('key', 'value');

option()->get('key'); // Returns 'value'

option()->has('key'); // Returns true

// Specify a default value for when the specified key does not exist
option()->get('non existing key', 'default') // Returns 'default'

option()->put('anotherKey', 'anotherValue');

// Put multiple items in one go
option()->put(['ringo' => 'drums', 'paul' => 'bass']);

option()->all(); // Returns an array with all items

option()->forget('key'); // Removes the item

option()->flush(); // Empty the entire options

option()->flushStartingWith('somekey'); // remove all items whose keys start with "somekey"

option()->increment('number'); // option()->get('number') will return 1 
option()->increment('number'); // option()->get('number') will return 2
option()->increment('number', 3); // option()->get('number') will return 5

// Option implements ArrayAccess
option()['key'] = 'value';
option()['key']; // Returns 'value'
isset(option()['key']); // Return true
unset(option()['key']); // Equivalent to removing the value
bash
php artisan vendor:publish --tag="laravel-option-config"