Download the PHP package consilience/laravel-message-flow without Composer

On this page you can find all versions of the php package consilience/laravel-message-flow. 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-message-flow

Latest Stable Version Total Downloads Latest Unstable Version License

Laravel Message Flow

Overview

Laravel Message Flow is a lightweight messaging system for passing structured data between Laravel applications. It is built entirely on Laravel's queue system — if two applications can connect to the same queue (Redis, database, SQS, or any other driver), they can exchange messages.

There are no external dependencies beyond Laravel itself. No message broker to install, no new protocols to learn — just queue connections you already know how to configure.

The original use-case was to replace fragile webhooks between a suite of applications with something easier to set up, monitor and maintain.

Concepts

Messages

A message is any JSON-serialisable data. Each message carries three things:

Outbound Flow

Sending a message is as simple as creating a MessageFlowOut model instance. An Eloquent observer detects the new record and dispatches it through a configurable routing pipeline that determines which queue connection and queue name to use, then pushes the message onto that queue.

The outbound message is stored in the message_flow_out table throughout this process, giving you a local audit trail of what was sent.

Inbound Flow

On the receiving application, a standard Laravel queue worker picks up the job and writes it to the local message_flow_in table as a MessageFlowIn model. Your application then handles the message via an Eloquent observer — the same pattern you already use for model events.

Once processed, the inbound message can be marked as complete, failed, or deleted, depending on your application's needs.

Routing Pipeline

The outbound routing pipeline is a sequence of configurable pipe stages (using Laravel's Pipeline) that each message passes through before being dispatched. The default pipeline routes the message to a queue based on its name (via config mappings), dispatches it, and optionally cleans up the local record.

You have full control over this pipeline. You can add custom routing logic, logging, duplicate detection, or anything else — each stage is a simple class implementing a handle method.

Message Statuses

Both inbound and outbound messages track their lifecycle through a status column:

Outbound (MessageFlowOut):

Status Meaning
new Created, waiting to be routed and dispatched
queued Successfully dispatched to the queue
complete Fully processed (dispatched, optionally acknowledged)
failed Could not be dispatched — can be retried

Inbound (MessageFlowIn):

Status Meaning
new Received, waiting for the application to handle
complete Successfully processed by the application
failed Processing failed — can be retried

Failed messages are never automatically deleted, so they can be inspected and retried. Completed messages can be cleaned up with the message-flow:purge artisan command or by enabling the DeleteCompleteMessage pipe in the outbound routing pipeline.

Optionally, acknowledgement messages can be sent in the reverse direction to confirm end-to-end delivery:

Configuration Overview

Role What to configure
All apps Shared Redis entry + queue entry (Steps 1-2), identical on every app
Sender Outbound routing in message-flow.php (Step 3)
Receiver Queue worker + Eloquent observer (Step 4)

For two-way communication, each app is both sender and receiver — see Two-Way Communication below.

Installation

Requirements

Install Using Composer

Publish Migrations and Config

You can then run php artisan migrate to migrate the database.

Setting Up a Shared Queue (Redis Example)

This example uses Redis, but any queue driver supported by Laravel will work. The same four steps apply regardless of driver.

The Three Config Layers

Laravel uses the word "connection" at several levels, which can be confusing. Setting up a shared queue touches three config files, each at a different layer:

Layer Config file What it names
Redis server config/database.php How to reach a Redis instance and which key prefix to use
Queue config/queue.php A named queue that uses a particular Redis server entry as its backend
Message Flow config/message-flow.php Which named queue to push messages onto

No changes to your existing Laravel defaults are needed — we just add new entries alongside them.

Step 1 — Redis Server Entry

config/database.php

Add a Redis entry with a fixed prefix so that every application sharing the queue sees the same keys, regardless of each app's global Redis prefix:

Step 2 — Queue Entry

config/queue.php

Add a queue entry that uses the Redis entry from Step 1 as its backend:

Steps 1 and 2 are identical on every application sharing the same message flow. They define the shared transport — not who sends or receives.

Step 3 — Sender: Outbound Routing

config/message-flow.php

Tell Message Flow which queue name to push outbound messages onto. Name each queue after the receiver — this keeps things unambiguous regardless of how many senders push to it:

Different message names can route to different receivers:

Send a message by creating a MessageFlowOut record:

An Eloquent observer dispatches the message through the routing pipeline automatically — no additional code needed on the sender side.

Step 4 — Receiver: Worker and Observer

Start a worker listening on the queue name that senders push to:

The first argument (message-flow-queue) is the queue entry from Step 2. The --queue flag is the queue name from the sender's Step 3 config.

Create an observer to handle incoming messages:

Register the observer in a service provider:

Two-Way Communication

When two applications need to send messages to each other, both act as sender and receiver. The shared infrastructure (Steps 1–2) stays identical on both apps. Each app just needs:

Name each queue after the receiver. This makes it clear who consumes which queue, regardless of how many senders push to it.

Core app Fulfilment app
Redis entry (Step 1) message-flow-redis message-flow-redis (identical)
Queue entry (Step 2) message-flow-queue message-flow-queue (identical)
Sends to (Step 3) queue-name: 'to-fulfilment' queue-name: 'to-core'
Worker listens on (Step 4) --queue=to-core --queue=to-fulfilment

Core's config/message-flow.php:

Fulfilment's config/message-flow.php:

Both apps share a single Redis entry and a single queue entry — only the outbound queue-name and the worker's --queue flag differ.

For one-way messaging, only the sender needs Step 3 and only the receiver needs Step 4. For two-way, each app does both.

Artisan Commands

This package introduces a few new artisan commands:

Create Message

This command allows you to create a new outbound message.

php artisan message-flow:create-message \
    --name='routing-name' \
    --payload='{"json":"payload"}' \
    --status=new

If no options are provided, the name will be default, the status new and the payload an empty object.

List Messages

This command will list the messages currently in the cache tables. These are messages that are being sent, or have been sent and have not yet been deleted. They are also messages that have been received and also not been deleted.

php artisan message-flow:list-messages \
    --direction={inbound|outbound} \
    --status={new|complete|failed|other} \
    --uuid={uuid-of-message} \
    --limit=20 \
    --page=1 \
    --process

The status and uuid options can take multiple values.

The limit option sets the number of records returned. This is effectively the page size.

The page option specifies which page (of size limit) to display. Page numbers start at 1 for the first page.

The process option will dispatch jobs for messages that have not yet been processed. For outbound messages that will be matching messages in the new or failed states. This will generally only be needed for testing or kicking off failed observers. For inbound messages in the new state, this will fire the eloquent created event to kick the custom observers into action.

With the -v option, the payload will be included in the listing. Some payloads may be large.

Purge Messages

This command deletes old messages from the inbound and/or outbound cache tables. By default it purges records with a complete status that were last updated more than 30 days ago.

php artisan message-flow:purge \
    --days=30 \
    --hours=0 \
    --direction={inbound|outbound|both} \
    --status={complete|failed} \
    --dry-run

The --days and --hours options are combined to set the age threshold. For example, --days=1 --hours=12 purges records older than 36 hours, and --days=0 --hours=6 purges records older than 6 hours.

The --direction option defaults to both. Abbreviations are accepted (e.g. --direction=in or --direction=out).

The --status option can be specified multiple times to purge records in more than one status. It defaults to complete if not specified.

The --dry-run option shows how many records would be deleted without actually deleting them.

Running manually

Purge all completed messages older than 30 days from both tables:

php artisan message-flow:purge

Purge completed and failed inbound messages older than 7 days:

php artisan message-flow:purge --days=7 --direction=inbound --status=complete --status=failed

Preview what would be deleted:

php artisan message-flow:purge --days=14 --dry-run

Scheduling

To run the purge automatically, add it to your application's scheduler.

In routes/console.php (Laravel 11+):

Or in a service provider's boot() method:

Testing

Tests use Orchestra Testbench and PHPUnit:

TODO


All versions of laravel-message-flow with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ^10.0|^11.0|^12.0
php Version ^8.4
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 consilience/laravel-message-flow contains the following files

Loading the files please wait ...