avto-dev / rabbitmq-api-client
RabbitMQ API 客户端实现
v2.7.0
2024-04-26 10:59 UTC
Requires
- php: ^8.1
- ext-json: *
- ext-mbstring: *
- composer/package-versions-deprecated: ^1.11
- guzzlehttp/guzzle: ^7.7
- illuminate/config: ~10.0 || ~11.0
- illuminate/contracts: ~10.0 || ~11.0
- illuminate/support: ~10.0 || ~11.0
Requires (Dev)
- laravel/laravel: ~10.0 || ~11.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
README
RabbitMQ API 客户端
此包将 RabbitMQ API 客户端实现添加到您的 PHP 应用程序中。
安装
使用以下命令通过 composer 安装此包
$ composer require avto-dev/rabbitmq-api-client "^2.0"
需要已安装
composer
(如何安装 composer)。
您需要修复包的主要版本。
之后,您可以使用以下命令“发布”包配置文件
$ php artisan vendor:publish --provider="AvtoDev\\RabbitMqApiClient\\Frameworks\\Illuminate\\LaravelServiceProvider"
用法
首先,您应该创建 API 客户端实例
<?php use AvtoDev\RabbitMqApiClient\Client; use AvtoDev\RabbitMqApiClient\ConnectionSettings; $client = new Client(new ConnectionSettings('http://127.0.0.1:15672', 'guest', 'guest')); // And after that you can execute API commands, for example: $client::version(); // Client version, like `1.0.0` $client->healthcheck(); // `true` or `false` $client->queueInfo('some-queue-name'); // Object with information about queue
如果您正在使用具有已注册包服务提供者的 Laravel 框架,您可以使用 DI 解析客户端实例,例如
<?php namespace App\Console\Commands; use AvtoDev\RabbitMqApiClient\ClientInterface; class SomeCommand extends \Illuminate\Console\Command { /** * The console command name. * * @var string */ protected $name = 'some:command'; /** * Execute the console command. * * @param ClientInterface $client * * @return void */ public function handle(ClientInterface $client): void { $client->healthcheck(); // `true` or `false` } }
测试
对于包测试,我们使用 phpunit
框架和 docker-ce
+ docker-compose
作为开发环境。因此,在克隆存储库后,只需在终端中写下以下命令
$ make build $ make latest # or 'make lowest' $ make test
变更日志
变更日志可以在此处找到。
支持
如果您发现任何包错误,请在此存储库中创建一个问题。
许可证
这是一个开源软件,许可协议为MIT 许可证。