Download the PHP package texthtml/php-lock without Composer

On this page you can find all versions of the php package texthtml/php-lock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-lock

php-lock

Build Status Latest Stable Version License Total Downloads Scrutinizer Code Quality

php-lock is a library that makes locking on resources easy. It can be used to avoid access to a file during write operations or to prevent crontabs to overlap. And it's designed to integrate well with Dependancy Injection (eg Symfony Container or Pimple).

Installation

With Composer :

Usage

You can create an object that represent a lock on a file. You can then try to acquire that lock by calling $lock->acquire(). If the lock fail it will throw a \TH\Lock\Exception (useful for CLI tools built with Symfony Console Components documentation). If the lock is acquired the program can continue.

Locking a file exclusively

Sharing a lock on a file

Auto release

$lock->release() is called automatically when the lock is destroyed so you don't need to manually release it at the end of a script or if it got out of scope.

Using lock for crontabs

When you don't want some crontabs to overlap you can make a lock on the same file in each crontab. The TH\Lock\LockFactory can ease the process and provide more helpful message in case of overlap.

When process 1 is running and we start process 2, an Exception will be thrown: "Could not acquire exclusive lock on protected resource" and if the factory was configured with a \Psr\Log\LoggerInterface, messages explaining what happend would be logged:

process 1: exclusive lock acquired on protected resource
process 2: could not acquire exclusive lock on protected resource
process 2: lock released on protected resource

The only LockFactory available at the moment is the TH\Lock\FileFactory. This factory autmatically create lock files for your resources in the specified folder.

Aggregating locks

If you want to simplify acquiring multiple locks at once, you can use the \TH\Lock\LockSet:

It will try to acquire all locks, if it fails it will release the lock that have been acquired to avoid locking other processes.

note: Lock put inside a LockSet should not be used manually anymore

Notes

Distributed system

On a distributed system, file based locking does not work, You can use the php-lock redis extension to have a safe lock instead.


All versions of php-lock with dependencies

PHP Build Version
Package Version
Requires psr/log Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package texthtml/php-lock contains the following files

Loading the files please wait ....