GitXplorerGitXplorer
a

symfony-signal-helper

public
5 stars
2 forks
0 issues

Commits

List of commits on branch master.
Verified
087829ed0a0538a64c454f4136bc1429ed2492c4

Helper function for iterables

aalexeyshockov committed 6 years ago
Verified
d1d2c8ebca1f0190902c7daece575c47e11e1fc4

Deps update

aalexeyshockov committed 6 years ago
Unverified
23dabf77c640cfd8e9fa8260e8312f2479088886

Symfony 3 support

aalexeyshockov committed 9 years ago
Unverified
e50e6ef791c33a665fe1f8cd7fad9bb6b739c4de

Better documentation

aalexeyshockov committed 9 years ago
Unverified
6e2d949bb832b87c20dae086ba29256b733fa07a

Initial code

aalexeyshockov committed 9 years ago
Unverified
9a96195482d121e47271d55af0c70db8b8270c8e

Initial commit

aalexeyshockov committed 9 years ago

README

The README file for this repository.

SignalHelper

Helper for Symfony Console to handle process signals (like termination).

Installation

$ composer require alexeyshockov/symfony-signal-helper

Usage

Just register the helper in your application (app/console, for example):

#!/usr/bin/env php
<?php

// ...

$console = new Application();

$console->getHelperSet()->set(new SignalHelper());

$console->run($input);

And use it inside your command:

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getHelper('signal');
        $helper->listen();
        
        while (true) {
            if (count(array_intersect([SIGINT, SIGTERM], $helper->takeSignals())) > 0) {
                // Stop by any of SIGINT or SIGTERM.
                break;
            }
            
            // Some business logic.
        }
    }