PHP code example of nedoto / laravel-client

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

    

nedoto / laravel-client example snippets




    declare(strict_types=1);

    namespace YourNamespace;

    // import the blic function retrieveNedotoConfiguration(): string {
            
            $response = NedotoClientFacade::get('my-slug'); // 1. call the "get()" method of the Nedoto facade with the slug you want to retrieve as a mandatory parameter
            
            return $response->getConfiguration()->getValue(); // 2. retrieve your value from the Configuration object
        }
    }



    declare(strict_types=1);

    namespace YourNamespace;

    // import the MyClass
    {
        private NedotoClient $nedotoClient;
        
        public function __construct(NedotoClient $nedotoClient) // 1. inject Nedoto Client
        {
            $this->nedotoClient = $nedotoClient;
        }
    
        public function retrieveNedotoConfiguration(): string {
            
            $response = $this->nedotoClient->get('my-slug'); // 2. call the "get()" method on the Nedoto Client with the slug you want to retrieve as a mandatory parameter
            
            return $response->getConfiguration()->getValue(); // 3. retrieve your value from the Configuration object
        }
    }

$response->getStatus(); // ex. 200

$response->failed(); // ex. true (if HTTP status code is different from 200)

$response->getErrors();

[
    0 => 'Error 1',
    1 => 'Error 2',
    1 => 'Error 3',
    // ...
]

$response->getConfiguration(); // return Nedoto\Configuration

$configuration->getValue(); // ex: it returns the value of the configuration defined in one of the configurations at https://app.nedoto.com/configurations

$configuration->getType(); // ex. integer

$configuration->getCreatedAt(); // DateTimeImmutable

$configuration->getUpdatedAt(); // ex. DateTimeImmutable
shell
php artisan vendor:publish --tag=nedoto-laravel-client