PHPackages                             laravel-addons/command-daemonizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. laravel-addons/command-daemonizer

ActiveLibrary[CLI &amp; Console](/categories/cli)

laravel-addons/command-daemonizer
=================================

Laravel/Lumen console command daemonizer with graceful shutdown

0.1.4(5y ago)330.1k↓50%MITPHPPHP &gt;=7.2.0

Since Jun 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/laravel-addons/command-daemonizer)[ Packagist](https://packagist.org/packages/laravel-addons/command-daemonizer)[ Docs](https://github.com/laravel-addons/command-daemonizer)[ RSS](/packages/laravel-addons-command-daemonizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

Laravel Command Daemonizer
==========================

[](#laravel-command-daemonizer)

**Run a Laravel console command as a long-lived process with gracefully shutdown.**

### Installation

[](#installation)

```
composer require laravel-addons/command-daemonizer
```

Laravel will automatically add the service provider `CommandDaemonizerServiceProvider` to the file `config/app.php` in `providers` option.

In Lumen, you MUST manually register the service provider `CommandDaemonizerServiceProvider` in `bootstrap/app.php` file:

```
$app->register(LaravelAddons\CommandDaemonizer\CommandDaemonizerServiceProvider::class);
```

### How to use

[](#how-to-use)

For example, run kafka consumer

```
use LaravelAddons\CommandDaemonizer\DaemonCommand;

class KafkaMessageConsumer extends DaemonCommand
{
    private $config;
    private $consumer;

    protected $signature = 'kafka-consumer';

    public function __construct(array $config)
    {
        parent::__construct();

        $this->config = $config;
    }

    protected function init(): void
    {
        $this->consumer = ... //initialisation of consumer
    }

    public function daemon(MyHandler $handler, LoggerInterface $logger): void
    {
        $message = $this->consumer->receive();

        try {
            if ($message instanceof RdKafkaMessage) {
                $handler->handle($message);
                $this->consumer->acknowledge($message);
            }
        } catch (Throwable $e) {
            $logger->error($e->getMessage());
        }
    }
}
```

1. You MUST implement method `daemon()`. This method will run in an endless loop.
2. You can use constructor to inject your dependency or inject dependency in `daemon()` method. Your dependencies will be resolved.
3. You can override the empty parent method `init()` to run some code before starting the daemon.

### Options

[](#options)

`DaemonCommand` append some options to you command:

```
--force : Force the worker to run even in maintenance mode
--memory=128 : The memory limit in megabytes
--sleep=0 : Number of seconds to sleep at each iteration in a loop
--timeout=60 : The number of seconds a child process can run

```

### Gracefully shutdown

[](#gracefully-shutdown)

Since daemonized commands are long-lived processes, they will not pick up changes to your code without being restarted. So, the simplest way to deploy an application using daemonized commands is to restart the commands during your deployment process. You may gracefully restart all of the daemonized commands by issuing the `daemon-command:restart`:

```
php artisan daemon-command:restart
```

This command will instruct all daemonized commands to gracefully "die" after they finish processing their current step in loop. Since the daemonized commands will die when the `daemon-command:restart` command is executed, you should be running a process manager such as [Supervisor](http://supervisord.org/) to automatically restart the daemonized commands.

This library uses the cache to store restart signals, so you should verify a cache driver is properly configured for your application before using this feature.

Based on [Illuminate Queue Worker](https://github.com/illuminate/queue/blob/master/Worker.php).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

2165d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3952b6141e47b5a2423e70ba3b83a674b19085e11e380e4abe243f293907f440?d=identicon)[vyacheslav-startsev](/maintainers/vyacheslav-startsev)

---

Top Contributors

[![vyacheslav-startsev](https://avatars.githubusercontent.com/u/25704924?v=4)](https://github.com/vyacheslav-startsev "vyacheslav-startsev (9 commits)")

---

Tags

consolelaravelcommanddaemondaemonizergraceful shutdown

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-addons-command-daemonizer/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-addons-command-daemonizer/health.svg)](https://phpackages.com/packages/laravel-addons-command-daemonizer)
```

###  Alternatives

[nunomaduro/laravel-console-menu

Laravel Console Menu is an output method for your Laravel/Laravel Zero commands.

815412.0k48](/packages/nunomaduro-laravel-console-menu)[illuminated/console-mutex

Mutex for Laravel Console Commands.

146938.2k1](/packages/illuminated-console-mutex)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
