Download the PHP package fast-forward/clock without Composer

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

FastForward\Clock

PHP Version Composer Package PSR-20 Tests Coverage License

FastForward\Clock provides PSR-20 compliant clock implementations and seamless integration with Fast Forward Container.

This package offers two clock implementations: SystemClock for production time and FrozenClock for deterministic testing.

โœจ Features

๐Ÿ“ฆ Installation

Requirements:

๐Ÿ› ๏ธ Usage

Basic: Get the current time

The simplest way to get the current time is using SystemClock:

With a specific timezone

Using with Fast Forward Container

For larger applications, use the service provider to register the clock in your container:

Freezing time for tests

Use FrozenClock to create deterministic tests:

FrozenClock accepts multiple input formats:

Using FrozenClock with Fast Forward Container in tests

๐Ÿงฐ API Summary

Class Description
FastForward\Clock\SystemClock PSR-20 clock that returns current system time with optional timezone
FastForward\Clock\FrozenClock PSR-20 clock that returns a fixed time (ideal for testing)
FastForward\Clock\ServiceProvider\ClockServiceProvider Registers clock services in Fast Forward Container

SystemClock Constructor

Parameter Type Description
$timezone DateTimeZone\|string\|null Timezone for the clock (defaults to system default)

FrozenClock Constructor

Parameter Type Description
$clock DateTimeInterface\|ClockInterface\|string\|int\|float The time to freeze. Accepts DateTimeImmutable, string (relative or absolute), timestamp, or another ClockInterface

๐Ÿ”Œ Integration

This package integrates seamlessly with:

๐Ÿ“ Directory Structure

โš™๏ธ Advanced / Customization

Custom timezone via configuration

If you use Fast Forward Config, you can configure the default timezone:

Creating a custom clock

Both clocks are final readonly classes, but you can wrap them:

โ“ FAQ

Q: What's the difference between SystemClock and FrozenClock?
A: SystemClock returns the current time and is suitable for production. FrozenClock returns a fixed time and is ideal for testing.

Q: Which interface should I use in my application?
A: Use Psr\Clock\ClockInterface for maximum portability. Both implementations satisfy this interface.

Q: How do I freeze time in tests?
A: Use FrozenClock directly, or register it via ArrayServiceProvider before ClockServiceProvider.

Q: Can I use this without Fast Forward Container?
A: Yes! Simply instantiate SystemClock or FrozenClock directly in your code.

Q: Does this work with other PSR-11 containers?
A: Yes. The clocks are standalone classes that don't require any container.

Q: How do I set a specific timezone?
A: Pass a timezone string or DateTimeZone instance to the SystemClock constructor.

๐Ÿ›ก License

This project is licensed under the MIT License.

๐Ÿค Contributing

Issues, documentation improvements, and pull requests are welcome!

๐Ÿ”— Links


All versions of clock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
fast-forward/config Version ^1.4
fast-forward/container Version ^1.6
psr/clock Version ^1.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 fast-forward/clock contains the following files

Loading the files please wait ...