Download the PHP package mouf/utils.common.lock without Composer

On this page you can find all versions of the php package mouf/utils.common.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 utils.common.lock

Lock Manager

The LockManager package is a simple package that provides functions to get a lock. Typically, you want to use locks when you want to be sure that 2 actions do not happen at the same time. For instance, if you regularly schedule cron tasks, you might want to be sure the last cron task is finished before running a new one. A lock can help you do that.

The Lock class

The Lock class represents a lock. You can acquire a lock to lock the resource and release the lock to set it free. Of course, if the lock has been already acquired by another user, you won't be able to acquire it yourself. You can optionnaly wait for the lock to be freed by the other process to acquire it yourself.

Internally, locks are acquired by putting a lock on a "file" that is hidden in the temp directory. When creating a Lock instance in Mouf, you will therefore have to find a unique temp name for that file.

If your PHP script crashes or exits without explicitly releasing the lock, the lock will be automatically released, so that other processes can use the lock.

Example

A first example: trying to acquire a lock without waiting

A second example: acquire a lock and wait if the lock is not available

Good practices

A good practice is to create the lock object via a dependency injection mechanism. This way, you can share instances of your lock accross services that require it. The Mouf framework let's you do that. Let's assume you create a "myLock" instance:

Your code to use the lock would look this:


All versions of utils.common.lock with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 mouf/utils.common.lock contains the following files

Loading the files please wait ....