Download the PHP package ayesh/php-timer without Composer

On this page you can find all versions of the php package ayesh/php-timer. 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 php-timer

PHP Timer

Latest Stable Version License Scrutinizer Code Quality CI codecov SensioLabsInsight Too many badges

Synopsis

A helper class to calculate how long a particular task took.

This class is similar to phpunit/php-timer, but not a fork, nor mimic its functionality.

Prerequisites

Installing

The simplest way would be to install using composer.

If, for some reason you can't use Composer, or don't want to (oh come on!), you can integrate the class with your current PSR-4 autoloader by mapping Ayesh\PHP_TIMER namespace to the repository's src folder.

Usage

It is pretty simple to use the timer, with all methods being static, and allowing only 4 methods.

Start timer

This starts the timer (actually keeps the current time stored) with the keydefault`. Throughout the library, if you do not provide a specific key, this default key is used.

Alternately, you can start the timer with a given key:

Once you start the time with a given key, you can use the same key to refer to that particular timer. You can of course use PHP magic constants to make things easier:

Attempting to start the timer with a non-string key will throw a \TypeError exception. You can call the start method multiple times even if the timer has started. It will not reset the timer.

Read timer

After starting the timer, you can read the elapsed time at any time. Reading the time will not stop the timer. You can read the timer, do some expensive calculations, and read again to get the cumulative time.

Attempting to read a timer that is not started will throw an \LogicException exception.

Formats

You can pass a second argument to let this library make minimal processing for you:

See the formats section below for the formats supported.

Stop timer

You can stop the timer anytime as well. This makes the library store the stop time, and your further Timer::read() calls will always return the time it took between start and stop.

Attempting to stop a timer that is not started will throw an \LogicException exception.

Reset timer

By default, starting the timer after stopping it will continue it from where it left off. For example, if you have 3 seconds on the timer when you stop it, and start it again, the total time will start from 3 seconds. You can explicitly reset the timer to make it start from 0. Resetting the timer will not make the timer start again. You need to explicitly start the timer again with a Timer::start() call.

Formats

Currently, the following formats are provided:

Examples

Calculate the timer one-off:

`

Stop watch functionality, with stop-and-go timer calculated separately.

`

Development and tests

All issues are PRs are welcome. Travis CI and PHPUnit tests are included. If you are adding new features, please make sure to add the test coverage.

Credits

By Ayesh Karunaratne and contributors.

kthxbye


All versions of php-timer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.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 ayesh/php-timer contains the following files

Loading the files please wait ....