PHP code example of lullabot / drupal-symfony-lock

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

    

lullabot / drupal-symfony-lock example snippets




$backend = \Drupal::lock();
$store = new \Lullabot\DrupalSymfonyLock\DrupalStore($backend);
$factory = new \Symfony\Component\Lock\Factory($store);
$lock = $factory->createLock('lock-identifier', 10);

// Blocking means this will throw an exception on failure.
$lock->acquire(true);