2017 © Pedro Peláez
 

symfony-bundle lock-command-bundle

Features for Symfony commands

image

kaliop/lock-command-bundle

Features for Symfony commands

  • Friday, May 18, 2018
  • by gggeek
  • Repository
  • 5 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 4 Open issues
  • 2 Versions
  • 170 % Grown

The README.md

Kaliop Lock Command Bundle

Installation

Configure repository

$ php composer.phar config repositories.kaliopConsoleBundle '{ "type": "vcs", "url": "https://github.com/kaliop/kaliop-lock-command-bundle.git" }'

Install bundle

$ php composer.phar require kaliop/lock-command-bundle

Add bundle to the Symfony kernel

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new Kaliop\LockCommandBundle\LockCommandBundle(),
            ...
        ];
    }
}

Remove bundle

$ php composer.phar remove kaliop/lock-command-bundle

Usage

Command locker

This bundle gives the possibility to "lock" console commands in order to prevent concurrent execution., (*1)

In order to do so, you have to declare your command as a service and tag it with lock: true, (*2)

services:
    test.console.command:
        class: AppBundle\Command\TestLockCommand
        tags:
            - { name: "console.command", lock: true }

As you can see, the console.command tag has available a new lock option, which can be set to either true or false. Commands registered with the lock option set to true will be locked at the command start event and unlocked at the command terminate or exception event., (*3)

Additionally, if needed, you can pass a --no-lock option on the command line when launching a command if you don't want the command to be locked for a single execution:, (*4)

$ php bin/console kaliop:command:example --no-lock

The Versions