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 -Umgebung, fügen Sie die Umgebungsvariable hinzu
NACOS_AUTH_ENABLE=true(der Standardwert ist falsch)
Wenn der Benutzername und das Kennwort korrekt sind, lautet die Rückgabeinformationen wie folgt
{
"accessToken" : " eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTY0NzUwMzcxMX0.m1p2WKSz1TNj3ftUgKSJuj7Yu4SdoQiV-k0rm6IbvFg " ,
"tokenTtl" : 18000 ,
"globalAdmin" : true ,
"username" : " nacos "
} Wirf NacosAuthException -Ausnahme aus
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
Komponist
composer dumpautoload
Phpstan
vendor/bin/phpstan analyse srcPHP-CS-FIXER
vendor/bin/php-cs-fixer fix src__toString() -Methode wird verwendet, wie eine Klasse reagieren soll, wenn sie als Zeichenfolge behandelt wird. Zum Beispiel echo $ obj; Was sollte angezeigt werden.WARNUNG: Ausnahmen können nicht in die Methode __toString () vor dem PHP 7.4.0 geworfen werden. Dies kann zu tödlichen Fehlern führen.
__invoke() Beim Versuch, ein Objekt in Form einer Aufruffunktion aufzurufen, wird die Methode __invoke () automatisch aufgerufen.__callStatic() wird aufgerufen, wenn __callstatic () eine unzugängliche Methode in einem statischen Kontext aufruft.