Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Confluent Schema Registry Api Laravel Package

mateusjunges/confluent-schema-registry-api

A PHP library for consuming the Confluent Schema Registry REST API, offering low-level PSR-7 compliant requests plus high-level abstractions for easier developer experience. Includes async and sync APIs, caching support, and integration with Avro and Guzzle.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Laravel Integration: The package aligns well with Laravel’s event-driven architecture (e.g., queues, listeners) by providing a synchronous/asynchronous API for schema operations. This enables seamless validation of Kafka events (e.g., order_created) against registered schemas before processing.
  • Microservices Schema Governance: Supports cross-service schema consistency in polyglot Laravel microservices (e.g., PHP + Kafka + Java services) by centralizing schema management via Confluent’s registry. Integrates with Laravel’s service container for dependency injection.
  • Avro/Protobuf Support: Leverages flix-tech/avro-php for schema parsing, which is critical for Laravel apps using Kafka Avro serialization (e.g., via rdkafka or laravel-kafka). Ensures compatibility with Confluent’s schema evolution rules.
  • PSR-7/PSR-18 Compliance (Updated in 9.1.0): Now built on Guzzle 8 / promises 3 / psr7 3, while remaining backward-compatible with Guzzle 7 stacks. This aligns with Laravel 11/12’s default HTTP client (Illuminate\Http\Client) and reduces the risk of version conflicts with other Laravel packages that have already moved to Guzzle 8. The PSR-7 boundary means the registry client can be swapped for Illuminate\Http\Client-backed implementations or custom middleware for schema validation.

Integration Feasibility

  • Laravel Service Provider: Can be bootstrapped as a Laravel service provider to bind the PromisingRegistry/BlockingRegistry to the container, enabling dependency injection in controllers/jobs.
    // app/Providers/SchemaRegistryServiceProvider.php
    public function register() {
        $this->app->singleton(PromisingRegistry::class, function ($app) {
            return new PromisingRegistry(
                new Client(['base_uri' => config('kafka.schema_registry_url')])
            );
        });
    }
    
  • Queue Workers/Jobs: Ideal for asynchronous schema validation in Laravel queue jobs (e.g., processing Kafka events). The PromisingRegistry allows non-blocking schema checks before publishing events.
  • API Request Validation: Can validate incoming API requests (e.g., Illuminate\Validation) against schemas stored in the registry, ensuring consistency between HTTP payloads and Kafka topics.
  • Event Listeners: Useful for post-publish validation of Kafka events (e.g., after order_created is published, verify its schema matches the registry).
  • Guzzle 8 Dependency Convergence (New): The 9.1.0 release removes a notable integration blocker for greenfield Laravel 11/12 apps and for monorepos already on guzzlehttp/guzzle:^8. Previously, adopting this package forced a Guzzle 7 downgrade across sibling packages. This is a low-effort, high-value upgrade for teams currently pinned to guzzlehttp/promises:^2.0.

Technical Risk

Risk Area Mitigation Strategy
Async API Complexity Use BlockingRegistry for synchronous workflows (e.g., API validation) and PromisingRegistry for background jobs. Document clear use cases.
Schema Evolution Leverage Confluent’s built-in schema compatibility checks. Add Laravel middleware to reject incompatible schemas.
Caching Overhead Start with CachedRegistry in development; monitor cache hit ratios before enabling in production.
Dependency Updates On 9.1.0+ you can pin either guzzlehttp/promises:^2.0 or ^3.0 and guzzlehttp/psr7:^2.0 or ^3.0. Keep avro-php at ^4.1. Validate with composer why-not before bumping.
Guzzle 7→8 Cutover (New) 9.1.0 supports both majors, but mixed-version installs in a monorepo can resolve unpredictably. Pin guzzlehttp/guzzle explicitly and run composer update --with-dependencies in a branch, not in CI auto-updates.
PSR-7 v3 Behavioral Changes (New) PSR-7 3.x normalizes header casing and stream semantics. If you wrap the registry client with custom middleware, add regression tests against header normalization and retry policies.
Error Handling Wrap registry calls in Laravel’s try-catch blocks and log SchemaRegistryException via Monolog.
PHP 8+ Requirement Ensure Laravel app uses PHP 8.1+ (LTS) and update composer.json to enforce this.

Key Questions

  1. Guzzle Upgrade Timing:
    • Do we migrate the app to Guzzle 8 now (leveraging 9.1.0’s dual support) or defer? Identify sibling packages already on guzzlehttp/guzzle:^8 that this release unblocks.
  2. Schema Registry Hosting:
    • Will the registry run on Confluent Cloud (managed) or self-hosted (e.g., Kafka + Schema Registry on-prem)? This affects caching, latency, and cost.
  3. Schema Evolution Strategy:
    • Does the team need custom compatibility rules beyond Confluent’s defaults (e.g., strict backward compatibility)? If so, extend the AvroSchema class or use middleware.
  4. Performance Requirements:
    • For high-throughput apps (e.g., 10K+ events/sec), will caching (e.g., Redis via Psr16CacheAdapter) be critical? Benchmark CachedRegistry vs. direct API calls.
  5. Testing Strategy:
    • How will schema registry interactions be tested? Use the package’s integration tests (Docker-based) or mock PromisingRegistry in unit tests. Add Guzzle 8-specific regression tests post-upgrade.
  6. Monitoring:
    • Should schema registry latency/metrics be exposed via Laravel’s Prometheus or Datadog integrations? Add middleware to track schemaId/subject lookups.
  7. Fallback Mechanism:
    • If the registry is unavailable, should Laravel fail gracefully (e.g., queue events for later) or reject requests? Implement a circuit breaker (e.g., spatie/flysystem-circuit-breaker).

Integration Approach

Stack Fit

  • Laravel Core:
    • Service Container: Bind the registry to Laravel’s DI system for easy access in controllers, jobs, and listeners.
    • Validation: Use the registry to validate API requests (e.g., Illuminate\Validation\Rule) or Kafka payloads.
    • Events: Attach listeners to KafkaEventPublished or JobProcessed to validate schemas post-publication.
  • Kafka Integration:
    • Producers: Validate schemas before publishing events (e.g., in App\Jobs\PublishKafkaEvent).
    • Consumers: Validate schemas on consumption (e.g., in App\Listeners\HandleKafkaEvent).
  • Caching Layer:
    • Use Redis (via Psr16CacheAdapter) or Doctrine Cache for CachedRegistry to reduce registry API calls.
    • Cache schema IDs by hash (default: md5((string) $schema)) or override with sha1 for consistency.
  • HTTP Client Layer (Updated):
    • On 9.1.0, prefer guzzlehttp/guzzle:^8 to match Laravel 11/12 defaults; Guzzle 7 remains supported for apps mid-upgrade. Avoid mixing majors across a monorepo; if unavoidable, isolate the registry client in its own package boundary.

Migration Path

  1. Phase 0: Dependency Audit (New)
    • Run composer why-not guzzlehttp/guzzle ^8 and composer why-not guzzlehttp/promises ^3 to map blockers.
    • Confirm flix-tech/avro-php:^4.1 is untouched — 9.1.0 does not change Avro parsing.
  2. Phase 1: Proof of Concept (PoC)
    • Install the package and test basic operations (e.g., register, schemaForId) in a local Kafka/Laravel setup.
    • Verify compatibility with existing Avro schemas and Laravel’s rdkafka/laravel-kafka packages.
  3. Phase 2: Core Integration
    • Bind the registry to Laravel’s service container.
    • Add schema validation to API requests (e.g., StoreOrderRequest) and Kafka producers.
  4. Phase 3: Guzzle 8 Cutover (New)
    • Upgrade to the latest 9.1.x, then bump guzzlehttp/guzzle to ^8. Run the package’s Docker integration suite (make phpunit-integration) plus app-level contract tests.
    • Watch for PSR-7 3 header-casing and stream regressions in any custom middleware.
  5. Phase 4: Performance Optimization
    • Enable CachedRegistry with Redis and measure cache hit ratios.
    • Implement circuit breakers for registry failures (e.g., retry 3x, then queue events).
  6. Phase 5: Monitoring & Governance
    • Add logging for schema operations (e.g., SchemaRegistry::register() calls).
    • Integrate with Laravel’s Prometheus or Datadog for metrics.

Compatibility

Component Compatibility Notes
Laravel Works with Laravel 8+ (PHP 8.1+ recommended). Tested with guzzlehttp/guzzle v7+ and (as of 9.1.0) v8.
Guzzle / PSR-7 9.1.0 adds support for guzzlehttp/guzzle:^8, guzzlehttp/promises:^3, and guzzlehttp/psr7:^3, retaining backward compatibility with v7/v2.
Kafka Clients Compatible with rdkafka (PHP extension) or laravel-kafka for Avro serialization.
Caching Backends Supports Redis, Doctrine Cache, or PSR-16/PSR-6 adapters.
Schema Formats Primarily Avro (via avro-php). Protobuf support requires additional adapters.
Confluent Schema Registry Tested with Confluent Platform 5.2+. Ensure API endpoints match your registry version.

Sequencing

  1. Prerequisites:
    • Set up a Confluent Schema Registry (self-hosted or Confluent Cloud).
    • Configure Kafka topics with schema references (e.g., order-events → order-value subject).
    • Run the dependency audit above to confirm Guzzle target major.
  2. Laravel Setup:
    • Add dependencies (Guzzle 8 path shown; swap to ^7.0/^2.0 if not yet ready):
      composer require flix-tech/confluent-schema-registry-api:^9.1 \
        guzzlehttp/guzzle:^8.0 guzzlehttp/promises:^3.0 guzzlehttp/psr7:^3.0 \
        doctrine/cache
      
    • Configure config/kafka.php with registry URL and caching settings.
  3. Core Integration:
    • Create a service provider to bind the registry.
    • Add schema validation to API controllers and Kafka jobs.
  4. Advanced Features:
    • Implement caching (Redis) for high-throughput scenarios.
    • Add middleware for global schema validation (e.g., ValidateKafkaSchema).
  5. Testing:
    • Run integration tests with Docker (as per the package’s make phpunit-integration).
    • Mock the registry in unit tests for isolated validation logic.
    • Add regression tests covering Guzzle 8/PSR-7 3 header and stream behavior.

Operational Impact

Maintenance

  • Dependency Updates:
    • 9.1.0 is a low-risk minor with an important dependency-surface expansion (Guzzle 8 / promises 3 / psr7 3). No public API changes were flagged in the release notes, but transport-layer behavior is the primary risk surface.
    • Pin majors explicitly and pick one HTTP major per app:
      "require": {
        "flix-tech/confluent-schema-registry-api": "^9.1",
        "guzzlehttp/guzzle": "^8.0",
        "guzzlehttp/promises": "^3.0",
        "guzzlehttp/psr7": "^3.0",
        "flix-tech/avro-php": "^4.1"
      }
      
    • Use composer why-not and composer update --with-dependencies --dry-run before merging.
  • Version Discipline:
    • Upgrade to 9.1.x before attempting the Guzzle 8 bump on the app; this isolates package-level regressions from app-level ones.
    • Track SchemaRegistryException rates through the cutover window.

Support

  • Vendor/Docs Coverage: 9.1.0 introduces a new external contributor (@gpibarra), indicating widening maintainer attention to dependency currency. Confirm the README/CHANGELOG documents the dual-major support to avoid teams assuming a hard Guzzle 8 requirement.
  • Laravel Package Compatibility: If other Laravel packages are already on Guzzle 8, this release removes a prior composer conflict — expect faster, cleaner installs.
  • Escalation Path: For transport-layer issues post-upgrade, fall back to 9.0.x (Guzzle 7 only) while triaging; no schema-management functionality is lost.

Scaling

  • No change to throughput characteristics. Registry caching (CachedRegistry + Redis) remains the primary scaling lever.
  • For high-volume services, the asynchronous PromisingRegistry path is unchanged; batching registry lookups and caching by md5/sha1 schema hash remain the recommended pattern.
  • Guzzle 8’s underlying transport improvements are incremental — do not plan capacity changes around this release; benchmark CachedRegistry hit ratios as before.

Failure Modes

Failure Mode Impact Mitigation
Mixed Guzzle majors across monorepo (New) Non-deterministic dependency resolution; CI flakiness Enforce a single major via root composer.json constraints and CI composer validate.
PSR-7 3 header normalization regressions (New) Custom schema-validation middleware may mis-match headers or miss content-type checks Add contract tests against schemaForId/register with representative headers.
Registry unavailable Event publishing/validation blocked Circuit breaker + queue-and-retry pattern (unchanged).
Cache stampede on cold Redis Latency spike on registry calls Warm cache on deploy; use jittered TTLs.
Schema incompatibility at publish Producer rejection Pre-publish compatibility check via BlockingRegistry in the job pipeline.

Ramp-Up

  • Engineer Enablement: ~1 day for teams already on 9.0.x to adopt 9.1.0; add ~1–2 days for the Guzzle 7→8 cutover including dependency audit and regression tests.
  • Training Focus: HTTP client abstraction boundaries (PSR-7), registry caching strategies, and the async vs. sync registry selection. The dual Guzzle support means there is no forced migration deadline — plan the cutover on your own release cadence.
  • First Deliverable: PoC validating one producer and one consumer path against a real registry within the first sprint, followed by the Guzzle upgrade as an isolated PR.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel