Download the PHP package andrewdyer/metrics without Composer

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

Metrics

A metrics library for Eloquent applications that calculates strongly typed aggregates over a configurable date range.

Latest Stable Version Total Downloads License PHP Version Require

Introduction

This library provides Eloquent-based metric calculations, returning strongly typed result objects for scalar aggregates, time-grouped trends with zero-filled gaps, and categorical breakdowns, all with JSON serialisation support. It works in any PHP application with an Eloquent connection, including outside Laravel via the Capsule manager.

Prerequisites

Installation

Getting Started

1. Set up Eloquent

This library requires an Eloquent connection. In a Laravel application this is configured automatically. Outside of Laravel, bootstrap Eloquent using the Capsule manager:

2. Create a metric

Extend Value and implement calculate() to define the query, and getStartDate() / getEndDate() to define the date range:

Usage

Calculating a metric

Call calculate() on any metric instance to run the query and return a typed result:

JSON serialisation

All result objects implement JsonSerializable:

Customising the metric name and description

Override getName() and getDescription() on any metric to provide a human-readable label:

Rounding

Override getRoundingPrecision() and getRoundingMode() to control how aggregate values are rounded:

Metric Types

Value

A Value metric calculates a single aggregate over a date range. When the model uses timestamps, the date filter defaults to created_at. When the model does not use timestamps, no date filter is applied unless an explicit $dateColumn is passed.

Count

Returns the number of records within the date range:

To filter by a specific date column, pass it explicitly:

On models without timestamps, no date filter is applied unless an explicit column is given:

Sum

Totals the values of a column across all matching records:

Average

Calculates the mean value of a column across all matching records:

Minimum

Returns the smallest value of a column within the date range:

Maximum

Returns the largest value of a column within the date range:

Trend

A Trend metric calculates an aggregate grouped over time at a given frequency. Missing dates within the range are automatically filled with zero values.

When the model uses timestamps, the date column defaults to created_at. When the model does not use timestamps, an explicit $dateColumn must be passed or an InvalidArgumentException is thrown.

Extend Trend and implement calculate(), getStartDate(), getEndDate(), and getFrequency():

Calculating the metric returns a keyed array of labels to aggregate values:

Supported frequencies

Count

Tracks how many records fall within each period of the date range:

Sum

Totals a column's values for each period across the date range:

Average

Calculates the mean value of a column for each period in the range:

Minimum

Returns the lowest value of a column recorded within each period:

Maximum

Returns the highest value of a column recorded within each period:

Partition

A Partition metric calculates an aggregate grouped by a categorical column, returning a key-value breakdown. Results are filtered to the configured date range.

When the model uses timestamps, the date filter defaults to created_at. When the model does not use timestamps, no date filter is applied unless an explicit $dateColumn is passed.

Extend Partition and implement calculate(), getStartDate(), and getEndDate():

Calculating the metric returns a keyed array of group labels to aggregate values:

Count

Groups records by a column and counts how many fall into each category:

To filter by a specific date column, pass it explicitly:

Sum

Groups records by a column and totals a second column within each group:

Average

Groups records by a column and calculates the mean of a second column per group:

Database Support

The following database drivers are supported:

Driver Minimum Version
MySQL 5.7+
MariaDB 10.2+
SQLite 3.38.0+
PostgreSQL 9.4+

License

Licensed under the MIT licence and is free for private or commercial projects.


All versions of metrics with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/database Version ^11.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 andrewdyer/metrics contains the following files

Loading the files please wait ...