<?php
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\Store\FlockStore;
$path = __DIR__ . '/tmp';
$lockKey = new Key('my_lock');
$store = new FlockStore($path);
$lock1 = new Lock($lockKey, $store);
// no lock by $lock1 yet
dump($lock1->isAcquired());
// aquire lock
$lock1->acquire(true);
// already locked by $lock1
dump($lock1->isAcquired());
// new handler, same name and path
$lock2 = new Lock($lockKey, $store);
// $lock2 cannot aquire lock of $lock1
dump($lock2->isAcquired());
// release first lock
$lock1->release();
// second try to aquire lock after $lock1 release
dump($lock2->isAcquired());