webman nacos readonly
v0.1.0
composer require tinywan/nacos use Tinywan Nacos Nacos ;
$ nacos = new Nacos ();
$ login = $ nacos -> auth -> login ( ' nacos ' , ' nacos ' );
var_dump ( $ login -> getBody ()-> getContents ());Docker environment, add the environment variable
NACOS_AUTH_ENABLE=true(the default value is false)
If the user name and password are correct, the return information is as follows
{
"accessToken" : " eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTY0NzUwMzcxMX0.m1p2WKSz1TNj3ftUgKSJuj7Yu4SdoQiV-k0rm6IbvFg " ,
"tokenTtl" : 18000 ,
"globalAdmin" : true ,
"username" : " nacos "
} Throw NacosAuthException exception
use Tinywan Nacos Nacos ;
$ nacos = new Nacos ();
$ response = $ nacos -> config -> get ( ' database ' , ' DEFAULT_GROUP ' );
if ( false === $ response ) {
var_dump ( $ nacos -> config -> getMessage ());
} use Tinywan Nacos Nacos ;
$ nacos = new Nacos ();
$ content = [
' listen ' => ' http://0.0.0.0:8888 ' ,
' transport ' => ' tcp ' ,
' context ' => [],
' name ' => ' webman-admin ' ,
];
$ response = $ nacos -> config -> publish ( ' aliyun ' , ' DEFAULT_GROUP ' , json_encode ( $ content ));
if ( false === $ response ) {
var_dump ( $ nacos -> config -> getMessage ());
} use Tinywan Nacos Nacos ;
$ nacos = new Nacos ();
$ optional = [
' groupName ' => ' webman-group ' ,
' clusterName ' => ' webman ' ,
' namespaceId ' => ' webman ' ,
' weight ' => 99.0 ,
' metadata ' => '' ,
' enabled ' => true ,
' ephemeral ' => false
];
$ response = $ nacos -> instance -> register ( ' 127.0.0.1 ' , 8888 , ' webman-admin ' , $ optional );https://nacos.io/zh-cn/docs/auth.html
composer
composer dumpautoload
phpstan
vendor/bin/phpstan analyse srcphp-cs-fixer
vendor/bin/php-cs-fixer fix src__toString() method is used to how a class should respond when it is treated as a string. For example, echo $obj; what should be displayed.Warning: Exceptions cannot be thrown in the __toString() method prior to PHP 7.4.0. Doing so can lead to fatal errors.
__invoke() When trying to call an object in the form of a calling function, the __invoke() method is automatically called.__callStatic() is called when __callStatic() calls an inaccessible method in a static context.