nitra/timeout-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

nitra timeoutbundle

Installs: 44

Dependents: 0

Suggesters: 0

Security: 0

Type:symfony-bundle

dev-master 2014-11-19 13:27 UTC

This package is not auto-updated.

Last update: 2018-05-06 20:32:10 UTC


README

Ограничение по времени выполнения PHP кода

Подключение

Пример

Подключение

composer.json

{
    ...
    "require": {
        ...
        "nitra/timeout-bundle": "dev-master",
        ...
    }
    ...
}

app/AppKernel.php

<?php
//...
class AppKernel extends Kernel
{
    //...
    public function registerBundles()
    {
        //...
        $bundles = array(
            //...
            // NitraTimeoutBundle
            new Nitra\TimeoutBundle\NitraTimeoutBundle(),
            //...
        );
        //...
        return $bundles;
    }
    //...
}

Пример отправки

controller.php

// ...
        // получить сервис
        $timeout = $this->container->get('nitra.timeout');
        
        // выполнить php код с ограничением по времени
        $val = $timeout->process(function(){
            $foo = 0;
            while($foo < 100000000) {
                ++$foo;
            }
            return $foo;
        }, 1000000);
// ...