2017 © Pedro Peláez
 

library command-lockable-trait

Symfony console command lockable trait

image

devcreel/command-lockable-trait

Symfony console command lockable trait

  • Sunday, October 15, 2017
  • by DevCreel
  • Repository
  • 0 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 40 % Grown

The README.md

CommandLockableTrait version

Symfony console command lockable trait (very simple emulation of multithreading), (*1)

Installation

Use

Add this to composer.json, (*2)

{
    "require": {
        "devcreel/command-lockable-trait": "1.0.*-dev"
    }
}

Usage

<?php

namespace TestBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use DevCreel\Command\LockableTrait;

class TestCommand extends ContainerAwareCommand
{
    use LockableTrait;

    //count of threads
    private $threadsCount = 5;

    protected function configure()
    {
        $this->setName('test:run');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        //check for free thread
        if (!$this->lock()) {
            $output->writeln('[' . $this->getName() . '] is already running in another process.');
            return 0;
        }

        //your code...

        //release thread
        $this->release();
    }

}

License

CommandLockableTrait is licensed under the MIT License, (*3)

The Versions

15/10 2017

dev-master

9999999-dev https://github.com/DevCreel/CommandLockableTrait

Symfony console command lockable trait

  Sources   Download

MIT

command console symfony lockable

15/10 2017

v1.0.1

1.0.1.0 https://github.com/DevCreel/CommandLockableTrait

Symfony console command lockable trait

  Sources   Download

MIT

command console symfony lockable

15/10 2017

v1.0.0

1.0.0.0 https://github.com/DevCreel/CommandLockableTrait

Symfony console command lockable trait

  Sources   Download

MIT

command console symfony lockable