Download the PHP package notamedia/yii2-locker without Composer
On this page you can find all versions of the php package notamedia/yii2-locker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-locker
Yii2 Locker Extension
Extension includes following features:
- Activate/Deactivate resource lock by unique identifier.
- Check and block request if exists active lock.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json.
Configuration
To use this extension, simply add the following code in your application configuration:
- Note: you may set custom time for each resource, simple add to
lockTime
, key - resource class and value - time in seconds - Note: if your db driver non mysql, you need set custom
'initTimeExpressionValue' = '...'
and'diffExpressionValue' = '...'
- Note: if you want to use custom lock class, you need set new
LockInterface::class
definitions like
connect following actions in your controllers and configure routing
- Note: you may set
'lockManager' = '...'
attribute if your LockManager component has other key
attach behavior to check lock, or you can check by yourself
- Note: you may set
'lockManager' = '...'
attribute if your LockManager component has other key
connect and execute migration, example:
For yii2 > 2.0.10
For yii2 < 2.0.10 create new migration and use extends
Usage
Methods:
LockAction
- activates lock and returns204
status code if successfulUnlockAction
- deactivates lock and returns204
status code if successful
Exceptions
LockAnotherUserException
- exception if lock set another user, status code500
LockNotExistException
- exception if lock not exist, status code500
LockNotExpiredException
- exception if lock actual and its time not expired, status code500