nitra / timeout-bundle
此包已被废弃,不再维护。未建议替代包。
nitra timeoutbundle
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);
// ...