Download the PHP package bschmitt/laravel-amqp without Composer

On this page you can find all versions of the php package bschmitt/laravel-amqp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-amqp

Laravel AMQP Package

A detailed AMQP wrapper for Laravel and Lumen to publish and consume messages, especially from RabbitMQ. This package provides full support for RabbitMQ features including RPC patterns, management operations, message properties, and more.

Build Status CI Latest Stable Version License Total Downloads

Features

Core Features

Version 3.1.0+ New Features

Advanced Features

Planned Features

Status legend: [x] shipped · [~] partial / building blocks shipped (full feature still planned) · [ ] not started.

Many "partial" items already ship as a programmatic API or CLI; the outstanding work is usually a UI, native integration, or codegen layer. See the Features section above for the full list of already-shipped capabilities.

Observability


Developer Experience


Kubernetes & Cloud Native


Enterprise Messaging


Polyglot Microservices


Operations


Security


AI & Modern Features

Requirements

Laravel Minimum PHP Notes
8.x 7.3 Last Laravel version for PHP 7.3 / 7.4
9.x 8.0.2 Use PHP 8.0.2+ (not 8.0.0/8.0.1)
10.x 8.1
11.x / 12.x 8.2
13.x 8.3

Config supports both use + properties (current) and legacy default + connections layouts.

Installation

Composer

For Laravel 5.5+:

For Laravel < 5.5:

Quick Start

Publishing Messages

Consuming Messages

RPC Pattern

Listen to Multiple Routing Keys

Artisan Commands

The package registers five console commands. Handler classes must implement Bschmitt\Amqp\Contracts\MessageHandlerInterface or expose an __invoke($message, $resolver) method. The $resolver is the active consumer and provides acknowledge(), reject(), reply(), and stopWhenProcessed().

amqp:work — long-running worker

Option Description
--handler= Required. FQCN of your message handler
--connection= Connection name from config/amqp.php
--exchange= / --exchange-type= Override exchange settings
--routing-key=* Routing key(s) to bind (repeatable)
--prefetch-count= Enable QoS with this prefetch count
--max-messages=0 Stop after N messages (0 = unlimited)
--max-time=0 Stop after N seconds
--memory=128 Exit if memory exceeds MB
--stop-when-empty Exit when the queue is drained instead of waiting
--requeue-on-error Requeue messages when the handler throws

amqp:consume — process a fixed number of messages

Defaults to one message per invocation. Use --all to drain the queue.

amqp:listen — listen on routing keys

Creates an auto-deleted queue (unless --queue= or --no-auto-delete is set) and binds it to every supplied routing key.

amqp:publish — publish from the CLI

Use --delay-ms to schedule delivery (TTL+DLX by default, or --delay-strategy=plugin when the delayed-message exchange plugin is installed).

amqp:purge — empty a queue

Retry options on amqp:work

Option Description
--retry=N Wraps the handler in a RetryHandler and configures up to N retries (0 disables retries)
--retry-delay=ms Base delay between retries in milliseconds (default 1000)
--retry-backoff=fixed\|exponential Backoff strategy (default fixed)
--retry-multiplier=2.0 Growth factor for exponential backoff
--retry-max-delay=ms Cap for the computed retry delay (0 = uncapped)
--retry-jitter=ms Random jitter added to each retry delay
--dlq=name Override the dead-letter queue name (default {queue}.dlq)
--declare-topology Pre-declare the work + DLQ + retry queues before consuming
--contract= FQCN of a MessageContractInterface to deserialize bodies into (passed as 3rd handler arg)
--validate-schema Validate inbound JSON against the contract's schema() before invoking the handler

See Retry & Dead-Letter Abstractions for the full picture.

Example handler

Laravel Queue Driver

Use this package as a native Laravel queue backend so jobs can be dispatched with dispatch(), Queue::push(), and processed with php artisan queue:work.

1. Publish AMQP config

2. Add queue connection

Merge the example from config/queue-amqp.php into config/queue.php:

3. Set default queue connection (optional)

4. Run the worker

Jobs are published to your configured exchange with the queue name as the routing key. Delayed jobs use a TTL dead-letter queue per delay interval.

Delayed & released jobs

AmqpQueue::later() publishes to a per-TTL delay queue ({queue}.delay.{ttl_ms}) with x-dead-letter-exchange / x-message-ttl so RabbitMQ delivers the job back to the main queue when the delay expires. $job->release($seconds) uses the same mechanism.

Verify the driver

Full setup, architecture and troubleshooting: docs/content/queue-driver.md or the interactive docs site (docs/index.html).

Configuration

Laravel

Publish the configuration file:

Or manually copy vendor/bschmitt/laravel-amqp/config/amqp.php to config/amqp.php.

Lumen

Create a config folder in your Lumen root and copy the configuration file:

Register the service provider in bootstrap/app.php:

Configuration Example

Documentation

Comprehensive Guides

Wiki Documentation

Module Documentation

See docs/modules/ for detailed module documentation:

Examples

Fanout Exchange

Queue Management

Management API

Retry & Dead-Letter Abstractions

Three small primitives let you build production-grade retry pipelines without hand-rolling DLX wiring:

Declare the topology once

Consume with auto-retry / DLQ routing

When the handler throws:

  1. RetryHandler reads (and bumps) the x-retry-attempt application header.
  2. If the next attempt still fits the policy, the message is republished to orders.process.retry.{delayMs} with the computed TTL. RabbitMQ's DLX on that queue routes the message back to orders.process once the TTL expires.
  3. When the retry budget is exhausted, the handler rejects the message without requeue and RabbitMQ forwards it to orders.process.dlq via the work queue's x-dead-letter-exchange.
  4. The x-first-failed-at and x-last-error headers carry diagnostics forward across retries so DLQ inspection is meaningful.

Pick a policy

Wrap an existing handler manually

Driving the worker from the CLI

See docs/content/advanced.md and the unit tests under test/Unit/Retry* / test/Unit/DeadLetterTopologyTest.php for more examples.

Delayed Messaging & Publish Backoff

Schedule messages for later delivery or absorb transient broker errors on publish.

publishLater() — schedule delivery

DelayedPublisher creates a per-delay queue ({routing}.delayed.{ms}) with x-message-ttl and DLX routing back to the target exchange when using the default TTL strategy.

PublishBackoff — retry failed publishes

This is separate from consumer-side RetryHandler — it retries the publish call itself when the broker throws.

Typed Message Contracts & DTO Serialization

Define message shapes as plain PHP classes and let the package handle JSON encoding/decoding.

Swap the serializer via $amqp->setSerializer($mySerializer) when you need MessagePack, Avro, etc.

JSON Schema Validation

Contracts may expose a static schema() method returning a JSON Schema-style array. The package validates payloads on publish and consume using the bundled SchemaValidator (no external dependencies).

Invalid payloads raise Bschmitt\Amqp\Exception\SchemaValidationException with a list of pointer-style error messages. On the CLI, combine --contract with --validate-schema on amqp:work.

Supported keywords include type, required, properties, additionalProperties, enum, const, minimum/maximum, minLength/maxLength, pattern, format (email, uri, uuid, date, date-time), items, oneOf/anyOf/allOf/not, and more — see docs/content/advanced.md.

Production Infrastructure

Exchange topology builder

Declare an exchange and multiple bound queues in one fluent builder:

Shortcut: Amqp::exchangeTopology('events', 'topic')->bindQueue(...).

Quorum & priority queues

Resilient connections & connection pool

Correlation ID & distributed tracing

Bridge OpenTelemetry (or any APM) without a hard dependency:

Consumer lifecycle

See docs/content/production-features.md for the full reference.

SAGA, Events, Middleware & Testing

SAGA workflow

Compensations only run for steps that completed before the failure, in reverse order.

Laravel events

The package dispatches the following events through \Illuminate\Support\Facades\Event (and a local listener registry as a fallback for non-Laravel contexts):

Event When
Bschmitt\Amqp\Events\MessagePublishing Right before a publish is sent
Bschmitt\Amqp\Events\MessagePublished After a successful publish
Bschmitt\Amqp\Events\MessageReceived When a message is received by the consume pipeline
Bschmitt\Amqp\Events\MessageHandled After the handler completes
Bschmitt\Amqp\Events\MessageFailed When the handler throws

Listen in Laravel as usual:

Consume middleware

Wrap the consume handler with a pipeline:

Each middleware receives (AMQPMessage $message, callable $next) and can short-circuit by not calling $next.

Fake AMQP driver

In tests, replace the bound singleton with a recording fake:

The fake records both publish() and publishLater() calls; never touches the broker.

Async publishing with publisher confirms

AsyncPublisher keeps a single channel open with confirm_select and only waits for confirmations on flush(), so high-throughput publishers don't block on the per-message round-trip.

Scale & Interop

RPC abstraction

RpcCallResult exposes succeeded(), timedOut(), and body().

Cross-service / polyglot messaging

Standard headers (x-message-type, x-schema-version, x-source-service) let Node, Go, or Java consumers route messages without PHP DTOs.

Observability & queue metrics

Publish/consume paths increment MetricsCollector automatically when using publish(), consumeWithMiddleware(), or HighPerformanceWorker.

High-performance workers

CLI: php artisan amqp:work jobs --handler=App\\Handlers\\JobHandler --optimized

See docs/content/scale-and-interop.md for the full reference.

gRPC-lite RPC

A typed, service-oriented RPC layer that feels like gRPC but rides on RabbitMQ. Define a service once, then call it from any process with typed DTOs.

Define the service contract

Call from any client

Rpc::call() automatically:

Throws RpcTimeoutException if no reply arrives, or RpcException if the server returned an error envelope.

Serve on the server side

The handler may be an instance or a container-resolvable FQCN (Laravel only). Handler exceptions are wrapped into an _rpc_error envelope so the client raises a typed RpcException with the original message and class name.

Configurable

RPC latency & events

Every Rpc::call() records timing in Amqp::rpcMetrics() and dispatches Laravel events you can wire to Pulse, logs, or APM:

Lower-level RpcClient::call() also returns RpcCallResult::durationMs().

See docs/content/grpc-lite-rpc.md for the full reference.

Laravel Messaging Platform

A set of higher-level building blocks that turn the package from "an AMQP client" into a full microservice toolkit: service discovery, sagas, message contracts, dead-letter management, declarative retry, monitoring, automatic context propagation, an audit log, and an event bridge.

Service Discovery (Rpc::service(...))

Skip exchange/routing-key/queue gymnastics — register a short name and call by that name.

Rpc::service() accepts an alias or a service FQCN.

Saga Facade

Saga::make()->step()->compensate() with reverse-order compensation when a step throws.

Message Contracts (OrderCreated::dispatch(...))

TypedMessage now exposes make() and dispatch() (and dispatchLater() for the delayed-queue variant).

Dead-Letter Management

CLI:

Lifecycle events: DeadLetterDetected, DeadLetterReplayed, DeadLetterPurged.

Declarative Retry (#[Retry])

On PHP 7.x the attribute parses as a comment (the package still loads); call sites that want the attribute need PHP 8+.

Monitoring Dashboard

CLI:

Wire the snapshot into any HTTP route (Laravel, Symfony, Slim) to expose a JSON dashboard.

Causation ID Propagation

CorrelationContext::inheritFromMessage() now picks up the inbound message_id as the causation_id for everything published afterwards, so downstream services can trace "this happened because of that" through a chain.

Correlation Chain Visualisation

CorrelationChain walks the MessageStore, groups entries by correlation_id, and rebuilds the causation tree using the x-causation-id header — no UI server required.

CLI:

Sample output:

Laravel Pulse Integration

When laravel/pulse is installed the package auto-registers AmqpPulseRecorder and records the following metric types so they show up under Pulse::values($type) and in custom cards:

Type Key Value
amqp_publish routing key 1 (count)
amqp_handle queue duration (ms)
amqp_fail queue 1 (count)
amqp_rpc Service::Request (short name) duration (ms)
amqp_rpc_fail Service::Request 1 (count)
amqp_dlq dead-letter queue sampled msg count

Disable the auto-subscription in config/amqp.php:

The recorder is a silent no-op when Pulse is not installed — no exceptions, no log spam.

OpenTelemetry Bridge

OpenTelemetryTracePropagator plugs the open-telemetry/api SDK into the package's TracePropagatorInterface so that the active OTel span context is auto-injected into every AMQP traceparent / tracestate header.

When the SDK is absent the propagator falls back to W3C generation (W3cTracePropagator), so the same wiring works on stripped-down environments and in CI.

MessageStore (audit log / event-sourcing seed)

Implement MessageStoreInterface to back it with Eloquent / Redis / files for durable replay.

Async Laravel Events

Override amqpRouting(), amqpExchange(), or amqpPayload() on the event to customise routing.

Testing

The package includes comprehensive test coverage:

Test Requirements:

See Testing Guide for more information.

Version 3.1.0+ Highlights

New Methods

RPC:

Management:

Management API:

Helpers:

Note: For consume(), listen(), rpc(), and all management methods, you must resolve the Amqp instance from the container using $amqp = app('Amqp') or $amqp = resolve('Amqp'). The static facade Amqp:: works for publish() but not for consume() and other instance methods.

Kubernetes & Cloud Native

Liveness / readiness probes

Two complementary surfaces — HTTP routes for sidecars and a CLI for exec probes — both backed by the same HealthState + HealthCheck pair.

1. HTTP routes

Enable in config/amqp.php (or via AMQP_PROBES_ENABLED=true):

The service provider registers:

Method Path Response
GET /amqp/health/live 200 alive / 503 dead
GET /amqp/health/ready 200 ready / 503 not ready
GET /amqp/health/ combined snapshot

Wire it from your consumer:

2. CLI exec probe (sidecar / livenessProbe.exec.command)

Exit codes: 0 = healthy, 1 = unhealthy — exactly what livenessProbe.exec / readinessProbe.exec expect.

Consumer autoscaling recommendations

AutoscalingAdvisor is a pure function that turns a QueueMetrics snapshot into a recommended replica count and a ready-to-paste KEDA trigger:

CLI form:

The --keda output drops straight into a ScaledObject manifest under spec.triggers.

Laravel Cloud / managed hosting compatibility

LaravelCloud detects managed environments (Laravel Cloud, Forge, Vapor, Render, Fly.io) and, when amqp.cloud.auto_hydrate is true (default), parses an AMQP_URL / CLOUDAMQP_URL / RABBITMQ_URL DSN into the active connection block on register() — without overwriting explicit config:

Explicit AMQP_HOST / AMQP_USER / etc. still win. You can also call the detector directly:

Multi-region deployment support

Configure region-scoped connection keys, then resolve / fail over with locality preference:

Failed regions cool down for the configured window before re-entering rotation.


Backward Compatibility

Version 3.4.0 is fully backward compatible with previous versions. All existing code will continue to work without modifications.

Contributing

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

Credits

License

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

Support

For issues, questions, or contributions:


Version: 3.4.0
Status: Ready


All versions of laravel-amqp with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
php-amqplib/php-amqplib Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bschmitt/laravel-amqp contains the following files

Loading the files please wait ...