PHPackages                             jced-artem/singleton-command - 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. jced-artem/singleton-command

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

jced-artem/singleton-command
============================

Symfony singleton command. Command that can't be run in parallel before previous process stopped.

1.0.2(9y ago)124MITPHP

Since Dec 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jced-artem/singleton-command)[ Packagist](https://packagist.org/packages/jced-artem/singleton-command)[ Docs](https://github.com/jced-artem)[ RSS](/packages/jced-artem-singleton-command/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

singleton-command
=================

[](#singleton-command)

Symfony singleton command. Command that can't be run in parallel before previous process stopped. If you need to simply run symfony command only in one process and you don't want to use and manage lock files by yourself - this class is what you need :)

### Require

[](#require)

1. `symfony/console`
2. `jced-artem/lock-service` - uses this package to replace LockHandler because it can't work with several hosts. This is important here because command can be launched in several servers as cron with shared folder.

### Install

[](#install)

`composer require jced-artem/singleton-command`

### Example

[](#example)

```
class JobCommand extends SingletonCommand implements SingletonCommandInterface
{
    protected function configure()
    {
        $this
            ->setName('cron:job')
            ->addArgument('someArgument', InputArgument::REQUIRED)
        ;
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     */
    protected function beforeLock(InputInterface $input, OutputInterface $output)
    {
        // You can create dynamic lock-names if you need. If don't - just remove this method.
        $this->setLockName($this->getName() . ':' . $input->getArgument('someArgument'));
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return bool
     */
    public function lockExecute(InputInterface $input, OutputInterface $output)
    {
        // command code here
    }
}

```

And you need to use this command as service, so, your `services.yml` should looks like this:

```
parameters:
    lock_path: '/path/to/shared/folder/locks'

services:
    lock_service:
        class: AppBundle\Service\LockService
        arguments: ['%lock_path%']
        shared: false # shouldn't be shared if you want to have commands with different lock paths.
    command.cron_job:
        class: AppBundle\Command\JobCommand
        arguments: ['@lock_service']
        tags:
            - { name: console.command }

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~0 days

Total

3

Last Release

3490d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/694933bfd2d85dd295280dff0c339061f3652f3c65ad2a5427e429462b33e295?d=identicon)[jced\_artem](/maintainers/jced_artem)

---

Top Contributors

[![jced-artem](https://avatars.githubusercontent.com/u/1507915?v=4)](https://github.com/jced-artem "jced-artem (10 commits)")

---

Tags

symfonycommandlocksingleton

### Embed Badge

![Health badge](/badges/jced-artem-singleton-command/health.svg)

```
[![Health](https://phpackages.com/badges/jced-artem-singleton-command/health.svg)](https://phpackages.com/packages/jced-artem-singleton-command)
```

PHPackages © 2026

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