PHPackages                             azaharizaman/nexus-connector - 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. [API Development](/categories/api)
4. /
5. azaharizaman/nexus-connector

ActiveLibrary[API Development](/categories/api)

azaharizaman/nexus-connector
============================

Framework-agnostic integration hub for external API communication with retry, circuit breaker, and rate limiting support

v0.1.0-alpha1(1mo ago)022MITPHPPHP ^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-connector)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-connector)[ RSS](/packages/azaharizaman-nexus-connector/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (2)

Nexus\\Connector
================

[](#nexusconnector)

A framework-agnostic PHP package providing a standardized, central gateway for external API communication with built-in resilience patterns.

Purpose
-------

[](#purpose)

`Nexus\Connector` solves the problem of **external communication complexity** by providing:

- **Vendor Abstraction**: Swap external providers (Mailchimp → SendGrid) without changing business logic
- **Resilience**: Built-in retry logic, circuit breaker, and rate limiting
- **Security**: Centralized credential management and request/response sanitization
- **Observability**: Comprehensive integration logging and metrics
- **Maintainability**: Clean separation between domain contracts and vendor implementations

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

[](#installation)

```
composer require azaharizaman/nexus-connector
```

Architecture
------------

[](#architecture)

### The Plugin/Adapter Pattern

[](#the-pluginadapter-pattern)

The package defines **domain-specific interfaces** (Email, SMS, Payment, etc.) that vendors adapt to. This enables zero-code vendor swapping.

```
┌─────────────────────────────────────────────────────┐
│         Nexus\Connector (Atomic Package)            │
│                                                      │
│  ┌────────────────────────────────────────────┐   │
│  │  Domain Interfaces (Contracts)             │   │
│  │  - EmailServiceConnectorInterface          │   │
│  │  - SmsServiceConnectorInterface            │   │
│  │  - PaymentGatewayConnectorInterface        │   │
│  └────────────────────────────────────────────┘   │
│                                                      │
│  ┌────────────────────────────────────────────┐   │
│  │  Core Services                              │   │
│  │  - ConnectorManager                         │   │
│  │  - RetryHandler                             │   │
│  │  - CircuitBreakerService                    │   │
│  │  - RateLimiterService                       │   │
│  └────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────┘
                        ▲
                        │ implements
                        │
┌─────────────────────────────────────────────────────┐
│          Nexus\Atomy (Application Layer)            │
│                                                      │
│  ┌────────────────────────────────────────────┐   │
│  │  Vendor Adapters                            │   │
│  │  - MailchimpEmailAdapter                    │   │
│  │  - SendGridEmailAdapter                     │   │
│  │  - TwilioSmsAdapter                         │   │
│  └────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────┘

```

Core Concepts
-------------

[](#core-concepts)

### 1. Domain Interfaces

[](#1-domain-interfaces)

Each service type has a dedicated interface:

- `EmailServiceConnectorInterface`: Transactional &amp; bulk email
- `SmsServiceConnectorInterface`: SMS messaging
- `PaymentGatewayConnectorInterface`: Payment processing
- `CloudStorageConnectorInterface`: File storage
- `ShippingProviderConnectorInterface`: Shipment tracking
- And 5 more...

### 2. Resilience Features

[](#2-resilience-features)

- **Retry Handler**: Exponential backoff with configurable attempts
- **Circuit Breaker**: Prevents cascading failures (opens after N failures)
- **Rate Limiter**: Token bucket algorithm per service/endpoint
- **Timeout Management**: Configurable request timeouts per endpoint
- **Idempotency Keys**: Prevents duplicate operations (e.g., duplicate payments)
- **OAuth Token Refresh**: Automatic access token renewal

### 3. Supporting Contracts

[](#3-supporting-contracts)

- `CredentialProviderInterface`: Secure credential retrieval with OAuth refresh
- `IntegrationLoggerInterface`: Audit trail for all external calls
- `WebhookVerifierInterface`: Signature validation
- `HttpClientInterface`: HTTP client abstraction for timeout enforcement
- `IdempotencyStoreInterface`: Response caching for duplicate prevention

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Nexus\Connector\Contracts\EmailServiceConnectorInterface;

class NotificationService
{
    public function __construct(
        private readonly EmailServiceConnectorInterface $emailConnector
    ) {}

    public function sendWelcomeEmail(string $recipient): void
    {
        $this->emailConnector->sendTransactionalEmail(
            recipient: $recipient,
            subject: 'Welcome to Nexus',
            body: 'Thank you for joining us!'
        );
    }
}
```

### Advanced Usage with Resilience Patterns

[](#advanced-usage-with-resilience-patterns)

```
use Nexus\Connector\Services\ConnectorManager;
use Nexus\Connector\ValueObjects\{Endpoint, HttpMethod, RateLimitConfig, IdempotencyKey};

class PaymentService
{
    public function __construct(
        private readonly ConnectorManager $connector
    ) {}

    public function processPayment(float $amount, string $currency, array $paymentData): array
    {
        // Create endpoint with rate limiting and custom timeout
        $endpoint = Endpoint::create('https://api.stripe.com/v1/charges', HttpMethod::POST)
            ->withRateLimit(RateLimitConfig::perSecond(100))
            ->withTimeout(45);

        // Generate idempotency key to prevent duplicate charges
        $idempotencyKey = IdempotencyKey::generate('payment');

        // Execute with automatic retry, circuit breaker, and OAuth refresh
        return $this->connector->execute(
            serviceName: 'stripe',
            endpoint: $endpoint,
            payload: [
                'amount' => (int)($amount * 100),
                'currency' => $currency,
                'source' => $paymentData['token'],
            ],
            idempotencyKey: $idempotencyKey
        );
    }
}
```

### Vendor Swapping (Application Layer)

[](#vendor-swapping-application-layer)

```
// config/connector.php
return [
    'email_vendor' => env('EMAIL_VENDOR', 'mailchimp'), // or 'sendgrid'
];

// app/Providers/ConnectorServiceProvider.php
$vendor = config('connector.email_vendor');

$adapter = match($vendor) {
    'mailchimp' => MailchimpEmailAdapter::class,
    'sendgrid' => SendGridEmailAdapter::class,
    default => throw new \Exception("Unsupported email vendor: {$vendor}"),
};

$this->app->singleton(EmailServiceConnectorInterface::class, $adapter);
```

Creating a Vendor Adapter
-------------------------

[](#creating-a-vendor-adapter)

1. Implement the domain interface
2. Use vendor SDK internally
3. Map domain methods to vendor API calls

```
namespace App\Connectors\Adapters;

use Nexus\Connector\Contracts\EmailServiceConnectorInterface;
use Mailchimp\Marketing\ApiClient;

class MailchimpEmailAdapter implements EmailServiceConnectorInterface
{
    public function __construct(
        private readonly ApiClient $client,
        private readonly string $listId
    ) {}

    public function sendTransactionalEmail(
        string $recipient,
        string $subject,
        string $body
    ): bool {
        $response = $this->client->messages->send([
            'message' => [
                'to' => [['email' => $recipient]],
                'subject' => $subject,
                'html' => $body,
            ],
        ]);

        return $response[0]['status'] === 'sent';
    }

    // Implement other interface methods...
}
```

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

[](#requirements)

- PHP 8.3 or higher
- No framework dependencies (pure PHP)

Documentation
-------------

[](#documentation)

### 📘 Package Documentation

[](#-package-documentation)

- **[Getting Started Guide](docs/getting-started.md)** - Quick start, core concepts, and basic configuration
- **[API Reference](docs/api-reference.md)** - Complete interface, value object, enum, and exception documentation
- **[Integration Guide](docs/integration-guide.md)** - Laravel and Symfony integration examples with database migrations
- **[Basic Usage Examples](docs/examples/basic-usage.php)** - Email, SMS, payment, and bulk email examples
- **[Advanced Usage Examples](docs/examples/advanced-usage.php)** - Custom endpoints, multi-tenant, webhooks, OAuth, cloud storage, metrics

### 📊 Implementation &amp; Planning

[](#-implementation--planning)

- **[IMPLEMENTATION\_SUMMARY.md](IMPLEMENTATION_SUMMARY.md)** - Implementation status, metrics, and key design decisions
- **[REQUIREMENTS.md](REQUIREMENTS.md)** - Detailed requirements tracking (110 requirements across 10 categories)
- **[TEST\_SUITE\_SUMMARY.md](TEST_SUITE_SUMMARY.md)** - Testing philosophy and application-layer integration test examples
- **[VALUATION\_MATRIX.md](VALUATION_MATRIX.md)** - Package valuation metrics and ROI analysis

### 🔗 Related Documentation

[](#-related-documentation)

- **[Root Implementation Docs](../../docs/CONNECTOR_IMPLEMENTATION.md)** - Original comprehensive implementation document
- **[Resiliency &amp; OAuth](../../docs/CONNECTOR_RESILIENCY_OAUTH_IMPLEMENTATION.md)** - Circuit breaker, retry logic, and OAuth implementation details

Integration
-----------

[](#integration)

Works seamlessly with other Nexus packages:

- **Nexus\\AuditLogger**: Automatic audit trail for all external calls
- **Nexus\\Setting**: Retrieve endpoint configurations and credentials
- **Nexus\\Tenant**: Multi-tenant credential isolation
- **Nexus\\Workflow**: Orchestrate multi-step integrations

License
-------

[](#license)

MIT License. See LICENSE file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.5% 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

Unknown

Total

1

Last Release

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (459 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (139 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-connector/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-connector/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-connector)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M710](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M370](/packages/easycorp-easyadmin-bundle)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M117](/packages/web-auth-webauthn-lib)

PHPackages © 2026

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