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
Mutex Bundle

Mutex Bundle Laravel Package

ixarlie/mutex-bundle

Provides named mutex locks for PHP applications, letting you guard critical sections and prevent race conditions. A simple API to acquire, wait for, and release locks around shared resources, background jobs, or scheduled tasks so only one process runs at a time.

View on GitHub
Deep Wiki
Context7

A Symfony bundle for Mutex implementation for PHP

Frequently asked questions about Mutex Bundle
Does ixarlie/mutex-bundle work with Laravel?
Not directly. It is a Symfony bundle, so its value comes from a DI extension, service definitions and a configuration tree that Laravel's container never reads. The reusable asset for a Laravel app is the underlying ixarlie/mutex core library and its storage adapters, which you would have to wire up yourself with a small service provider. Plan on roughly one to three engineering days for a spike and wrapper rather than a drop-in install.
How do I install and configure ixarlie/mutex-bundle in a Laravel application?
You can install it with Composer, but you cannot rely on Symfony bundle registration; you must register your own Laravel service provider, bind a MutexFactory or a specific adapter as a singleton, and optionally publish a config/mutex.php file. Keep the wrapper thin and expose one injectable contract or facade rather than scattering bundle classes through the codebase. Check the install with composer why-not first, because the bundle pulls Symfony components that Laravel also pins.
What is the difference between ixarlie/mutex-bundle and Laravel's Cache::lock()?
Laravel ships a first-party lock provider through Cache::lock(), backed by Redis, Memcached, database or file stores, with block, release and owner-aware release built in. ixarlie/mutex offers a similar abstraction plus adapters such as MySQL GET_LOCK, PostgreSQL advisory locks, flock and semaphores, which can matter where Redis is unavailable or undesirable. If Redis is already in your stack, Cache::lock() covers the same ground with official support, so a third-party mutex needs a concrete unmet requirement to justify it.
Which mutex backends does ixarlie/mutex support?
The core library ships adapters for Redis, MySQL GET_LOCK, PostgreSQL advisory locks, flock and semaphores, with a configurable strategy selected per named mutex. That flexibility is the main reason a Laravel team would look at it, since database-native locks can be preferable where running Redis is costly or operationally awkward. Confirm the specific adapter you need exists in the core ixarlie/mutex release line you pin, because the bundle wrapper adds configuration but no new backends.
How do I acquire, wait for, and release a lock with this package?
The API is deliberately small: create or inject a named mutex, call acquire with a blocking or non-blocking attempt, run the critical section, then release the lock. Watch TTL expiry against your job duration, and put release in a finally block so an exception cannot strand the lock. Ownership matters too, so only the process that acquired the lock should release it, especially on shared database backends.
What changed in ixarlie/mutex-bundle 3.0.0 and is it a breaking change?
The 3.0.0 release is essentially a Symfony package upgrade, with the maintenance effort going into the Symfony wrapper rather than the mutex core. The changelog gives no migration notes and no breaking-change description, so treat the semver-major as assume-breakage until you have diffed 2.1.0 against 3.0.0. If you only consume the core library, this release should not affect you, which is a good argument for pinning the core directly.
Could ixarlie/mutex-bundle cause Composer conflicts in a Laravel project?
Yes, and that risk went up with 3.0.0. A Symfony-major-driven release usually tightens constraints on symfony/dependency-injection, symfony/config and symfony/http-kernel, and Laravel pins its own ranges of those same packages. Run composer why-not to check for conflicts, and confirm the core ixarlie/mutex version you intend to use has no hard coupling to the Symfony 7.x line.
Should I type-hint Ixarlie\MutexBundle classes in my Laravel code?
No. Couple only to the core mutex interfaces so the Symfony wrapper can be dropped or replaced without touching application code. The 3.0.0 bump is a concrete example of why: it sends a breaking-change signal from a component you never actually run in Laravel. A thin contract of your own also makes it trivial to swap in Cache::lock() later if requirements change.
Is ixarlie/mutex-bundle actively maintained and safe for production?
It is a low-traffic package with a single maintainer, near-zero dependents and no meaningful downstream production-validation signal. The 3.0.0 tag shows the maintainer is still active, which is a positive, but the bus factor remains one. The MIT license mitigates this because you can fork or vendor the code, but budget that as a real maintenance commitment rather than a free fallback.
How should I test mutex-protected code in a Laravel application?
Bind a fake or in-memory lock implementation in the container during tests so you can assert that acquire and release wrap the critical section, then keep a small number of integration tests against the real backend. Cover the failure paths that actually bite: TTL expiring mid-job, a second process failing to acquire, and release being skipped after an exception. Clock skew across hosts and lock ownership on release are the subtle cases where bugs surface as silent duplicate execution instead of errors.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource