PHPackages                             wzaradzki/laravel-microservice-communicator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. wzaradzki/laravel-microservice-communicator

ActiveLibrary

wzaradzki/laravel-microservice-communicator
===========================================

Laravel package for handling microservice communication via Azure Service Bus REST API and Redis Streams

3(1y ago)017PHPPHP ^8.2

Since Oct 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/WZaradzki/laravel-microservice-communicator)[ Packagist](https://packagist.org/packages/wzaradzki/laravel-microservice-communicator)[ RSS](/packages/wzaradzki-laravel-microservice-communicator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Laravel Microservice Communicator
=================================

[](#laravel-microservice-communicator)

A Laravel package for handling microservice communication via Azure Service Bus REST API and Redis Streams.

Features
--------

[](#features)

- 🚀 Azure Service Bus integration using REST API
- 📡 Redis Streams support with auto-recovery
- ♻️ Easy switching between messaging systems
- 🔄 Automatic consumer group management
- 🛡️ Error handling and logging
- ⚡ Asynchronous message processing
- 🔌 Simple integration with Laravel
- ✨ Full Laravel 11 support

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.x
- Redis extension (for Redis driver)

Installation
------------

[](#installation)

```
composer require wzaradzki/laravel-microservice-communicator
```

For Laravel 11, ensure you're using the correct version:

```
composer require wzaradzki/laravel-microservice-communicator "^2.0"
```

The package will automatically register its service provider in Laravel 11's new service provider discovery system.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationServiceProvider"
```

Configure your environment variables in `.env`:

```
# Choose your primary driver
MICROSERVICE_COMMUNICATION_DRIVER=azure

# Azure Service Bus Configuration
AZURE_SERVICE_BUS_ENDPOINT=https://your-namespace.servicebus.windows.net
AZURE_SERVICE_BUS_KEY_NAME=your-key-name
AZURE_SERVICE_BUS_KEY=your-key

# Redis Configuration (if using Redis driver)
REDIS_STREAM_CONNECTION=default
REDIS_STREAM_GROUP=your_app_group
```

Usage with Laravel 11
---------------------

[](#usage-with-laravel-11)

### Basic Usage with Dependency Injection

[](#basic-usage-with-dependency-injection)

```
use WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationManager;

class YourService
{
    public function __construct(
        private readonly MicroserviceCommunicationManager $communicator
    ) {}

    public function sendMessage(): bool
    {
        return $this->communicator->publish('topic-name', [
            'event' => 'UserCreated',
            'data' => [
                'id' => 1,
                'email' => 'user@example.com'
            ]
        ]);
    }

    public function listenForMessages(): void
    {
        $this->communicator->subscribe('topic-name', function(array $message): void {
            logger()->info('Received message', $message);
            // Process your message
        });
    }
}
```

### Using with Laravel 11 Jobs

[](#using-with-laravel-11-jobs)

```
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationManager;

class ProcessMessage implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(
        private readonly array $message
    ) {}

    public function handle(MicroserviceCommunicationManager $communicator): void
    {
        $communicator->publish('processed-messages', [
            'original_message' => $this->message,
            'processed_at' => now()->toIso8601String()
        ]);
    }
}
```

### Using with Laravel 11 Events

[](#using-with-laravel-11-events)

```
use Illuminate\Foundation\Events\Dispatchable;
use WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationManager;

class MessageReceived
{
    use Dispatchable;

    public function __construct(
        public readonly array $message
    ) {}
}

// In your service provider
public function boot(): void
{
    Event::listen(function (MessageReceived $event) {
        // Process the message
    });
}
```

### Command Line Consumer with Laravel 11

[](#command-line-consumer-with-laravel-11)

```
use Illuminate\Console\Command;
use WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationManager;

class ConsumeMessages extends Command
{
    protected $signature = 'messages:consume {topic} {--driver=azure}';

    public function handle(MicroserviceCommunicationManager $communicator): void
    {
        $communicator->subscribe($this->argument('topic'), function(array $message): void {
            $this->info('Processing message: ' . json_encode($message));
            // Process message
        });
    }
}
```

Testing with Laravel 11
-----------------------

[](#testing-with-laravel-11)

The package includes Pest tests. To run them:

```
composer test
```

### Writing Tests

[](#writing-tests)

Example using Laravel 11's new testing features:

```
use WZaradzki\MicroserviceCommunicator\MicroserviceCommunicationManager;

test('message is published successfully', function () {
    $manager = Mockery::mock(MicroserviceCommunicationManager::class);

    $manager->shouldReceive('publish')
        ->once()
        ->with('topic-name', ['key' => 'value'])
        ->andReturn(true);

    $this->app->instance(MicroserviceCommunicationManager::class, $manager);

    // Test your code
    expect(/* your test */)
        ->toBeTrue();
});
```

Error Handling in Laravel 11
----------------------------

[](#error-handling-in-laravel-11)

```
use WZaradzki\MicroserviceCommunicator\Exceptions\BrokerException;
use Illuminate\Support\Facades\Log;

try {
    $communicator->publish('topic', $message);
} catch (BrokerException $e) {
    Log::error('Failed to publish message', [
        'error' => $e->getMessage(),
        'topic' => 'topic',
        'message' => $message,
        'trace' => $e->getTrace()
    ]);

    report($e); // Uses Laravel 11's error reporting
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request. Make sure to:

1. Follow Laravel 11 coding standards
2. Add tests for new features
3. Update documentation
4. Follow semantic versioning

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

560d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fba8d2fdfdd114aa4bb613572d30ad589fa10a471b5e62d8c1620933d3cf8297?d=identicon)[Wzaradzki](/maintainers/Wzaradzki)

---

Top Contributors

[![WZaradzki](https://avatars.githubusercontent.com/u/93011120?v=4)](https://github.com/WZaradzki "WZaradzki (4 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/wzaradzki-laravel-microservice-communicator/health.svg)

```
[![Health](https://phpackages.com/badges/wzaradzki-laravel-microservice-communicator/health.svg)](https://phpackages.com/packages/wzaradzki-laravel-microservice-communicator)
```

###  Alternatives

[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
