PHP code example of sunaoka / process-guard-php
1. Go to this page and download the library: Download sunaoka/process-guard-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sunaoka / process-guard-php example snippets
composer
use Sunaoka\ProcessGuard\Drivers\FileDriver;
use Sunaoka\ProcessGuard\LockFactory;
$driver = new FileDriver();
$factory = new LockFactory($driver);
$lock = $factory->create('Preventing Multiple Instances', ttl: 60.0);
if ($lock->acquire() === false) {
// already running
exit;
}
// You can do some processing
$lock->release();