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
Command Lock Bundle

Command Lock Bundle Laravel Package

ffreitas-br/command-lock-bundle

A Symfony bundle for locking console commands so scheduled jobs and long-running tasks don’t run concurrently. Prevent duplicate executions and race conditions by applying locks to individual commands with minimal configuration.

View on GitHub
Deep Wiki
Context7

Command Lock Bundle adds lightweight concurrency protection to Symfony console commands. It acquires a lock before a command executes and releases it afterward, preventing overlapping runs of long-running or scheduled tasks. Commands can opt in via configuration, with clear behavior when a lock is already held.

  • Prevents concurrent command execution
  • Simple Symfony Console integration
  • Configurable lock handling
  • Safe for cron and scheduled jobs
  • Lightweight bundle setup
Frequently asked questions about Command Lock Bundle
Can I install ffreitas-br/command-lock-bundle in Laravel?
It is a Symfony bundle, not a Laravel package. Laravel has no bundle registration concept and expects a ServiceProvider, optional Facade, and publishable config. Adoption in Laravel requires a port rather than a Composer install.
What does command-lock-bundle do?
It stops Symfony console commands from running concurrently by acquiring locks before execution. It is intended to prevent duplicate cron jobs, race conditions, and resource contention across single or multi-server deployments. The concept is useful for scheduled tasks and CI/CD pipelines, but the artifact is Symfony-specific.
Does command-lock-bundle support Laravel 10 or Laravel 11?
No. The bundle targets Symfony 2.2–2.5 and was last released in 2014, so it predates modern Laravel versions. Laravel 10 and 11 use modern PHP and Symfony console APIs that do not match the bundle's container wiring. Running it on PHP 8.1+ would likely require static analysis and a rewrite.
How do I prevent overlapping Laravel scheduled commands without this package?
Use Laravel's scheduler withoutOverlapping() method, for example $schedule->command('foo')->withoutOverlapping(10). For ad-hoc Artisan commands, use Cache::lock('cmd:foo', 300)->get() and release the lock in a finally block. These native primitives provide TTL and distributed correctness with Redis, Memcached, or DynamoDB stores.
Is there a Laravel alternative to command-lock-bundle?
Yes. Laravel's scheduler withoutOverlapping() and Cache::lock() cover most concurrent-invocation needs. symfony/lock standalone is also installable in Laravel and offers Redis, Postgres, Doctrine, and flock stores with configurable TTL. It is actively maintained and is the closest legitimate successor to what this bundle attempted in 2014.
How is command-lock-bundle configured per command?
The bundle wires lock behavior through Symfony's DI extension and Resources/config service definitions. You configure locks per command in Symfony service configuration, not in Laravel config files. In Laravel, equivalent per-command configuration would need to be implemented with a ServiceProvider or a custom command wrapper.
What lock backend does command-lock-bundle use?
The provided README excerpt does not specify the backend. Because it targets Symfony 2.2–2.5 from 2014, before symfony/lock existed, it likely uses a custom flock-on-file or cache-backed flag. You must verify whether it supports TTL, stale-lock reaping, and multi-host or NFS safety before relying on it.
Is command-lock-bundle safe for production multi-server cron jobs?
Unknown. The package has no visible CI, five stars, zero dependents, and one release from 2014, so there is no security response path or documented distributed correctness. It is unclear whether locks are TTL'd, released in finally or shutdown handlers, or safe on NFS and EFS volumes. A silently wrong lock is worse than no lock because it creates false confidence.
How do I test command locking in Laravel?
Use Cache::lock() with a fake or array cache store and assert that a second lock acquisition fails while the first is held. For scheduler tests, use withoutOverlapping() and run the scheduler twice to verify only one execution occurs. Always release locks in finally blocks and test stale-lock behavior with a short TTL.
Is command-lock-bundle actively maintained?
No active maintenance is evident. It has one release from 2014-06-02, five stars, zero dependents, no CI, and no issue tracker health. It targets PHP 5.4/5.5 and Symfony 2.2–2.5, so compatibility with PHP 8.1+ is unlikely without static analysis and a rewrite.
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