PHP code example of hyperf / nacos-sdk

1. Go to this page and download the library: Download hyperf/nacos-sdk 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/ */

    

hyperf / nacos-sdk example snippets




use Hyperf\NacosSdk\Application;
use Hyperf\NacosSdk\Config;
use Hyperf\Utils\Codec\Json;

$application = new Application(new Config([
    'username' => 'nacos',
    'password' => 'nacos',
    'guzzle_config' => [
        'headers' => [
            'charset' => 'UTF-8',
        ],
    ],
]));

$response = $application->auth->login('nacos', 'nacos');
$result = Json::decode((string) $response->getBody());

$response = $application->config->get('hyperf-service-config', 'DEFAULT_GROUP');
$result = Json::decode((string) $response->getBody());