thenexxuz/utils

A few common helpers for debugging. PID file lock out class and time measurement class.

1.3.0 2020-11-09 06:36 UTC

This package is auto-updated.

Last update: 2024-04-09 19:37:18 UTC


README

Build Status PHP from Packagist Packagist Version Packagist

Helpers

See the helper readme

Classes

MeasureTime

Use this class to measure response time when debugging or to include time in your API responses.

Usage

$time = new MeasureTime();

/* Do some stuff */

echo $time->mark(); /* Total time since $time was instantiated */

/* Do more stuff */

echo $time->markInterval(); /* Time since last mark()  */

/* Do even more stuff */

echo $time->mark(); /* Total time since $time was instantiated */

ProcessId

Create a PID file and lock out running the script multiple times.

Installation

composer require thenexxuz/utils

Usage

Add use TheNexxuz\Utils\ProcessId; to your file.

Within your code add the following to the start of your script.

$pid = new ProcessId('myScriptName');
$pid->setLock();

or

$pid = new ProcessId();
$pid->setScriptName('myScriptName');
$pid->setLock();

If no name is given then script is used.

You can check if the process is running (boolean returned).

$pid->isRunning()

Add the following to the end of your script.

$pid->releaseLock();

Testing

Run the tests with vendor/bin/phpunit --coverage-html build/coverage-report

Contributing

Please try to use GitFlow. More information here. And here.

  • Fork it!
  • Create your feature branch: git checkout -b feature/my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin feature/my-new-feature
  • Submit a pull request!

License

GPL v2