PHP code example of dorantor / filelock

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

    

dorantor / filelock example snippets



 
// create lock object
$lock = new \Dorantor\FileLock('path/to/file');

// ..and work with it
if ($lock->acquire()) {
    // file is locked
    $lock->release();
}
 
// ..or it could be
if (!$lock->acquire()) {
    // failed with lock
    return;
}
// file was locked
$lock->release();