Skip to content
docs.
WORKSPACE

Your documentation

Explore the project catalog
Localzet ServerАсинхронный PHP-серверTriangleФреймворк и компонентыMIX IDИдентификация и интеграцииHack APIПубличные API хакатонаACNПроект и компонентыUserlay / UserNetПроект и компоненты✓AxiomПроект и компонентыМесседжинг через почтуПроект и компонентыLWT / JWT / JOSEПроект и компонентыФинансовая аналитика KimaiПроект и компонентыМультипарадигмальная БДПроект и компонентыZorin PlatformПроект и компонентыZorin TrustПроект и компонентыFloraScope / VegwatchПроект и компонентыaegis-qДокументация проектаaevumdbДокументация проектаauditДокументация проектаauto-invest-managerАвтотрейдерcaine-companionДокументация проектаcertbot-cloudflareДокументация проектаClusterLocalzet Server / ClustercmdveilДокументация проектаConsolePHP CLICronБиблиотеки Localzet Serverdata-connectorДокументация проектаdevice-controlDevice Controlenn-projectДокументация проектаEventsБиблиотеки Localzet ServerflowsintДокументация проектаforgeДокументация проектаHttpClientБиблиотеки Localzet ServerinterpreterСобственный языкinvariaДокументация проектаkeynotesДокументация проектаknotrouteKnotroutelaravel-personal-analyticsДокументация проектаlocalzet-osДокументация проектаmeridianДокументация проектаMQTTБиблиотеки Localzet Servernano-kernelСобственная ОСNoterДокументация проектаpersonal-analyticsДокументация проектаProxyБиблиотеки Localzet ServerPSRБиблиотеки Localzet ServerPSR-7Библиотеки Localzet Serverrschs-monitorДокументация проектаsemsealДокументация проектаshardsealДокументация проектаSocketIOБиблиотеки Localzet ServerSOCKS5Библиотеки Localzet Serverstandalone-analyticsДокументация проектаstatic-php-cliДокументация проектаStorageБиблиотеки Localzet ServersutureДокументация проектаtempoweaveДокументация проектаttsСинтез речиTunnelБиблиотеки Localzet Serverui-kitUI KitvesperДокументация проектаWebAnalyzerWebAnalyzerzorin-access-brokerДокументация проектаzorin-authority-brokerДокументация проектаzorin-authority-sdk-phpДокументация проектаzorin-authority-sdk-pythonДокументация проектаzorin-authority-sdk-tsДокументация проектаzorin-client-intelДокументация проектаzorin-device-core-aospДокументация проектаzorin-host-agentДокументация проектаzorin-native-labДокументация проектаzorin-nodeДокументация проектаzorin-opsДокументация проектаdonstu-python-sdkДокументация проектаfloortraceFloortraceserver-rsLocalzet Server / Cluster
Catalog
Documentation/Userlay / UserNet

xray-grpc-php

PHP clients for the Xray gRPC API and protobuf message classes. Requires ext-grpc, grpc/grpc and google/protobuf as declared in composer.json.

Окно терминала
composer require localzet/xray-grpc
composer check-platform-reqs
ClassPurpose
Xray\App\Proxyman\Command\HandlerServiceClientInbound/outbound handlers
Xray\App\Log\Command\LoggerServiceClientLogging control
Xray\App\Router\Command\RoutingServiceClientRoutes and balancers
Xray\App\Stats\Command\StatsServiceClientTraffic counters and system statistics
Xray\Core\App\Observatory\Command\ObservatoryServiceClientObserved outbound status

Construct clients with an address and channel options. Unary RPC methods return a call object; wait() returns response/status. Check status.code before reading response fields. The timeout call option is measured in microseconds.

GetStats reads one named counter; QueryStats selects counters by pattern; GetSysStats returns process statistics. reset controls whether reading resets the counter. The example sets reset=false and a one-second deadline. Replace inbound tag example with your configured tag and enable the corresponding counters/API in Xray configuration.

The unencrypted example channel targets loopback. Protect remote transport and restrict access: this is an administrative Xray interface.

Client methods and message fields.

<?php
declare(strict_types=1);
use Grpc\ChannelCredentials;
use Xray\App\Stats\Command\GetStatsRequest;
use Xray\App\Stats\Command\StatsServiceClient;
require __DIR__ . '/vendor/autoload.php';
$client = new StatsServiceClient('127.0.0.1:10085', [
'credentials' => ChannelCredentials::createInsecure(),
]);
$request = new GetStatsRequest();
$request->setName('inbound>>>example>>>traffic>>>uplink');
$request->setReset(false);
[$response, $status] = $client->GetStats($request, [], ['timeout' => 1_000_000])->wait();
if ($status->code !== Grpc\STATUS_OK) {
throw new RuntimeException($status->details);
}
$stat = $response->getStat();
if ($stat === null) {
throw new RuntimeException('No statistic returned');
}
echo $stat->getValue(), PHP_EOL;

Source · AGPL-3.0