PHP code example of nocs / laravel-retriever

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

    

nocs / laravel-retriever example snippets




namespace Nocs\Retriever\Tests\Cache;

class Colors {

    public function red()
    {
        return 'red';
    }

}



$value = retriever()->get('colors.red');



namespace Nocs\Retriever\Tests\Cache;

class Colors {

    public function get()
    {
        return 'red';
    }

}



$value = retriever()->get('colors');



namespace Vendor\Package\Providers;

use Illuminate\Support\ServiceProvider;
use Nocs\Retriever\Support\Facades\Retriever;

class PackageServiceProvider extends ServiceProvider
{

    public function boot(Router $router)
    {

        Retriever::loadRetrieversFrom(__dir__.'/../Cache', 'package');

    }
}




$value = retriever()->get('my_vendor::colors');



$value = retriever()->get('key');
$value = retriever()->get('key', 'default');



$value = retriever('key', 'default');