Download the PHP package mattkingshott/statistics without Composer

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

Statistics

This package enables a Laravel application to maintain aggregated statistics for database tables. It serves as a companion package to (and relies upon) triggers.

Who is this for?

If you're running queries that are slow because they need to perform aggregations (COUNT, SUM, MIN, MAX or AVG) across many records, then you might get some value from this package. A common scenario where this takes place, is on a dashboard that displays lots of statistics e.g.

By contrast, you can configure the package to automatically maintain statistics in the background. So, instead of a slow query (like the above example), you can instead do this:

Or, better still, use the Eloquent model to query the data:

Table Values
Articles { "count" : 6 }
Projects { "count" : 3 }
Tasks { "count" : 2 }

Installation

Pull in the package using Composer:

Configuration

The package includes a configuration file that allows you to change the name of the database table that contains the aggregated values (the default is 'statistics'). If you want to change it, publish the configuration file using Artisan:

Usage

The package will automatically register and migrate a statistics table to your database. This table then serves as a repository for aggregated values. The values are maintained using database triggers, which will automatically fire after a record is inserted, updated or deleted.

Before proceeding further, it is important to remember that database triggers (which the package relies on) can only be added to a table after it has been created. In other words, don't try to create statistics for a table before it has been created by Schema::create (this will become clearer in the examples below).

To begin, add the InteractsWithStatistics trait to any Model class that you want to maintain statistics for e.g.

Next, call the static track method on the Model.

Next, call one or more of the available aggregation methods:

You can call an aggregation method more than once if you need to maintain statistics on multiple columns. Simply supply a custom name to differentiate them:

Finally, call the create method to install the triggers.

Example

Here's a simple example within a database migration:

Contributing

Thank you for considering a contribution to the package. You are welcome to submit a PR containing improvements, however if they are substantial in nature, please also be sure to include a test or tests.

License

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


All versions of statistics with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
mattkingshott/triggers 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 mattkingshott/statistics contains the following files

Loading the files please wait ....