PHP code example of overstar / php-nacos

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

    

overstar / php-nacos example snippets

 bash
composer 
 php
NacosConfig::setSavePath('path');
 php
// 参数:nacos地址,dataId,group,namespace
Nacos::init( "http://127.0.0.1:8848/", "console.php", "js", "0c1201b3-495a-4c14-9259-e798b64fb6e8" )
    ->run();
 php
Nacos::init( "http://127.0.0.1:8848/", "console.php", "js", "0c1201b3-495a-4c14-9259-e798b64fb6e8" )
    ->listener();
    
Nacos::init("http://127.0.0.1:8848/", ["db.php","web.php"], "js", "7e3d37db-2911-4074-950b-4b98b7a50243")
    ->listener();
 php
Nacos::init( "http://127.0.0.1:8848/", "console.php", "js", "0c1201b3-495a-4c14-9259-e798b64fb6e8" )
    ->publish("sdfsdfsdf","text");
 php
Nacos::init( "http://127.0.0.1:8848/", "console.php", "js", "0c1201b3-495a-4c14-9259-e798b64fb6e8" )
->delete();