Download the PHP package redbitcz/utils without Composer
On this page you can find all versions of the php package redbitcz/utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package utils
Redbit Utils
Lightweight utilities for logging, IO, and Unix-like process signal
Installation
Install via Composer:
Requirements
Package requires PHP version 7.3 and above.
For handling Unix-like process signals requires the pcntl
and posix
PHP extensions. Without that support
related method call will be siletly ignored.
Usage
Locker
The \Redbitcz\Utils\Lock\Locker
class is simple implementation of lock/semaphor based of filelock. It's optimized for
Linux architecture.
Locker support two modes:
- Blocking mode – Blocking mode is create semaphor for locked space, all concurrent locks will wait to release
previous lock. Be careful, it may cause to deadlock of PHP processes, because lock at filesystem is not subject of
max_execution_time
limit! - Non blocking mode – Non blocking mode is create lock which is prevent access concurrent processes to locked stage.
All concurent locks will imediatelly fails with
LockObtainException
Exception.
Example non-blocking lock:
See Non-blocking Locker
example.
Example blocking lock:
See Blocking Locker
example.
Logger
The \Redbitcz\Utils\Log\Logger
class is implementation of PSR-3 logger interface and it decorates each
logger record with time and log severity name.
Example:
Logger requires Writer \Redbitcz\Utils\IO\IOutStream
instance. Package contains few several types
of Writer implementations which are different by the log target (console, general output, standard output, HTML output,
or file).
Logger also support sectionalization for long-processing operations:
Example:
Sends to output:
Section is useful to provide logger to another service which is requested to process single entity.
See Logger
example.
Progress
The \Redbitcz\Utils\Log\Progress
class is simple generator of progress status to reporting progress of operations.
In additive is added the time spent is each step and whole operation.
Example:
See Progress
example.
ProcessTerminationLock
The \Redbitcz\Utils\Process\ProcessTerminationLock
class is simple mechanism how to prevent (rspt. delay) unexpected
exit of PHP process during operation processing. It's recommended to workers to prevent break during processing a job
and similar usage in processes managed by a Process Control system (systemd
, supervisor
, etc.).
Example:
See ProcessTerminationLock
example.
BitwiseVariator
Classes in \Redbitcz\Utils\Bitwise
namespace provides filtered bit variations generator over
Bitwise values.
That mean, when you have bits 1011
, variator generates all bits variations.
Variation for bits 1011 |
---|
0000 |
0001 |
0010 |
0011 |
1000 |
1001 |
1010 |
1011 |
Filters
BitwiseVariator
class provide filter to select variations with(out) some bits only.
Variation for bits 1011 with bite 0010 |
---|
0010 |
0011 |
1010 |
1011 |
Variation for bits 1011 without bite 0010 |
---|
0000 |
0001 |
1000 |
1001 |
Be aware to use more than 8 variated bits, because it proceed huge of variants:
(source: Spreadseed Bitwise Variator counts)
License
The MIT License (MIT). Please see License File for more information.
Contact
Redbit s.r.o. - @redbitcz - [email protected]