Download the PHP package bugfix666/laravel-outbox without Composer

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

Laravel Outbox

Latest Version on Packagist PHP Version Laravel Version License Run Tests

Transactional Outbox pattern implementation for Laravel 12+ and PHP 8.4+.

The package stores outgoing messages in the same database transaction as your business changes, then publishes them asynchronously through a configurable publisher.

Delivery semantics: the package provides at-least-once publication, not exactly-once delivery. A process can crash after a broker accepts a message but before the outbox row is marked as processed. Consumers must be idempotent.

Requirements

For concurrent production workers, use a database engine with reliable transactional row updates, such as PostgreSQL or MySQL/InnoDB. SQLite is useful for local development and tests, but is not a recommended high-concurrency outbox backend.

Installation

The package migrations create outbox_messages and add delivery-state columns (failed_at, last_error, locked_at, and lock_token). If you have already published and run the original migration, make sure the new additive migration is also published before running php artisan migrate.

Configuration

The published config/outbox.php file contains the following settings:

Environment variables:

lock_timeout is the lifetime of the cache lock that prevents overlapping processor commands. message_lock_timeout is the database lease for an individual message. Set the message lease longer than the maximum expected duration of a single publisher call. Expired leases can be reclaimed after a worker crash.

The model and migrations both respect outbox.table and outbox.connection.

Store a message in the business transaction

Always write the business change and the outbox message using the same database connection and transaction.

The aggregate_id column in the default migration is a UUID. If your aggregate uses another identifier format, customize the migration before running it.

The package's OutboxService::store() persists the message; it does not publish it immediately. The row is committed or rolled back together with the surrounding business transaction.

Run the processor

Run this command under a process supervisor or schedule it:

The processor claims messages with a database lease and a unique lock token. If a worker dies, another run can reclaim the message after message_lock_timeout. The cache lock is an additional guard against overlapping processor commands; it does not replace the database claim.

Publishers

Log publisher

LogPublisher is the default so a fresh installation can be exercised without a broker. It logs and marks messages as published; it does not deliver them to another service. Do not use it when events must reach a real consumer.

Queue publisher

The package includes QueuePublisher. It enqueues a package job, which dispatches the OutboxEvent Laravel event when the job runs.

You can listen for the event in your application:

The queue publisher uses the default queue. To route these jobs to another queue, bind an instance with the desired queue name in an application service provider:

Custom publisher

Implement OutboxPublisher to publish to RabbitMQ, Kafka, SNS, or another broker:

A publisher must return true only when the broker has accepted the message according to the durability guarantees required by your application. Returning false is treated as a failed attempt. Throwing an exception also schedules a retry.

The built-in KafkaPublisher requires the rdkafka PHP extension and checks the producer flush result. It is not installed as a dependency automatically.

Retry and failed messages

Failed publication attempts use exponential backoff:

min(max_delay_seconds, delay_seconds * multiplier ^ (attempts - 1))

When max_attempts is reached, the message receives failed_at and remains in the table for inspection. The most recent exception message is stored in last_error. Avoid putting secrets or sensitive payment data in exception messages.

Inspect failed messages:

After investigating and correcting the underlying issue, manually retry a failed message:

This resets its attempt counter and makes it immediately available. Use this deliberately: the consumer must be idempotent, especially if the previous delivery outcome was uncertain.

Monitoring

The package dispatches:

The service also logs publication failures. Monitoring listeners are isolated so an exception in an alerting listener does not change the delivery state.

Useful production metrics include:

Cleanup

Only successfully processed messages are removed by cleanup. Failed messages remain available for inspection.

Schedule cleanup according to your retention and audit requirements. Do not delete outbox records before the downstream system's recovery and reconciliation window has elapsed.

Delivery guarantees and consumer design

The outbox closes the dual-write gap between the business database transaction and recording the intent to publish. It cannot make a database and an external broker participate in one atomic transaction.

A broker can accept a message and the processor can crash before setting processed_at. The message may then be published again. This is why the package uses at-least-once delivery semantics.

Consumers should use a stable event ID or business reference and enforce deduplication with a database unique constraint. For financial operations, also use provider idempotency keys, ledger uniqueness constraints, and reconciliation for ambiguous external outcomes. Queue locks and unique jobs are not substitutes for business-level idempotency.

Tests

The test suite uses Orchestra Testbench and SQLite in-memory for fast functional coverage. Run additional integration tests against the same database engine and cache store used in production, especially for concurrent workers and broker publisher confirmations.

License

This package is licensed under GNU General Public License v3.0 only, consistent with the GPL-3.0-only declaration in composer.json.


All versions of laravel-outbox with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
laravel/framework Version ^12.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 bugfix666/laravel-outbox contains the following files

Loading the files please wait ...