Skip to content
forked from thenexxuz-zz/utils

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

License

Notifications You must be signed in to change notification settings

thenexxuz/utils

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TheNexxuz Utils

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%