Download the PHP package beacon-hq/metrics without Composer

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

Coverage Quality Gate Status

Beacon Metrics

Simple metrics and trends for Laravel

Installation

Features

Supported Aggregates

Supported Intervals

Usage

Value Metrics

Value metrics are simple single aggregate values and will typically result in a single value.

Value metrics can be calcuted using Metrics->value().

You can also get value metrics by group which will result in a Laravel Collection of values keys using the group value.

To enable grouping, use Metrics->byGroup(), passing in a column name or a SQL expression (i.e. DB::raw()):

With Previous

A common need is to get the metrics for the current period (e.g. today, this week) and the previous period (e.g. yesterday, last week), this can be achieved using the Metric->valueWithPrevious() method. This will return a Laravel collection.

Trend Metrics

Trends metrics allow you to get metrics for intervals of a time period, e.g. every day, every month, or multiples of an interval, e.g. every third day, every second month.

To set the period, use Metrics->by*($count), e.g. every third day would use $metrics->byDay(3).

Trends will always return a collection, with three keys:

Fill Missing Values

By default, only dates with results will be returned. To fill in missing values, use Metrics->fillMissing():

Percentage Values

To get results in percentages rather than absolute values, set the $inPercent argument to true when calling Metrics->trends().

Percentages are returned as a float with up to 2 decimal places.

Custom Queries

If you want metrics for a sub-set of data (e.g. a single category), you can simply add a where clause to the query passed to the Metrics::query() method.

Indexes

For performance, you need to have appropriate indexes on your tables. The following are recommendations based on testing, but you should always test with your own data to confirm.

If you are querying without a where clause, for MySQL/MariaDB and SQLite you should have an index on the date column (e.g. created_at):

For PostgreSQL, you should have an index on the date column (e.g. created_at) and the value column:

If you are querying with a where clause, you should also include the where column:

[!WARNING] The ordering in the column matters! Your where column should be first.

Defaults

Aggregate

By default, the package will use the count aggregate. If you want to use a different aggregate, you can use the appropriate aggregate method:

Interval

By default, the package will use a one day interval. If you want to use a different interval, you can use the Metrics->by*() methods to set the interval:

Date Column

By default, the package will use the created_at column for the date column. If you want to use a different column, you can use the Metrics->dateColumn() method to set the column name.

Date Range

By default, the package will use the previous month as the date range. If you want to use a different date range, you can use the Metrics->between(), Metrics->from(), or any of the Metrics->for*() methods to set the date range.


All versions of metrics with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
beacon-hq/bag Version ^2.6
illuminate/database Version ^10|^11|^12
illuminate/support Version ^10|^11|^12
nesbot/carbon Version ^3.8
ramsey/conventional-commits Version ^1.5.1
staudenmeir/laravel-cte Version ^1.9
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 beacon-hq/metrics contains the following files

Loading the files please wait ...