PHP code example of rych / lock

1. Go to this page and download the library: Download rych/lock 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/ */

    

rych / lock example snippets




$lock = new \Rych\Lock\Lock("lock-name", "/path/to/locks");
if ($lock->lock()) {
    // Do work here
} else {
    die ("Unable to acquire lock! Make sure no other process is running!");
}

$lock->unlock();