Download the PHP package ajimoti/cache-duration without Composer

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

PHP Cache Duration

Banner

Introduction

A readable and fluent way to generate PHP cache time.

Built and written by Ajimoti Ibukun

Quick Samples

Instead of this:

You can do this

You can also do this:

Requirements

Installation

You can install the package via composer:

Documentation

After installing the package via composer, import the Duration trait inside your class, then you are set.

Available methods

Method Expectations
seconds($value) Expects time in seconds
minutes($value) Expects time in minutes
hours($value) Expects time in hours
days($value) Expects time in days
at($value) Expects string, carbon instance, or DateTime instance

Dynamic calls

In addition to the methods provided above, the package uses PHP __callStatic() method to allow you make dynamic calls on the Duration trait.

For example, you want to get the number of seconds in 37 days, you can achieve this by calling a camel-case text of the number (thirtySeven in this case), plus the unit (Days in this case). That will leave us with something like this:

Note: The number in words MUST be in camel-case. Any other case will throw an InvalidArgumentException. Additionally, it must be followed by a title-case of the unit. The available units are Seconds, Minutes, Hours, and Days.

Usage

seconds($value)

Get time in seconds. It basically returns the same value passed into it.

minutes($value)

Converts time in minutes into seconds.

hours($value)

Converts time in hours into seconds.

days($value)

Converts time in days into seconds.

at($value)

This method allows you to convert a Carbon\Carbon instance, DateTime instance or string of date into seconds.

It returns the difference in seconds between the argument passed and the current timestamp.

The date passed into this method MUST be a date in the future. When a string is passed, the text MUST be compatible with Carbon::parse() method, else an exception will be thrown

Examples

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of cache-duration with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
nesbot/carbon Version ^2.55
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 ajimoti/cache-duration contains the following files

Loading the files please wait ....