Download the PHP package radiatecode/dastats without Composer

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

Da Stats

This package is a lightweight solution to record and view the statistics for the dashboard or reports. Sometimes we need KPI / Metrics / Statistics in our Dashboard Or Reports, to create those statistics we need to go through lots of calculation, queries etc. But this package may helps you to make statistics in nicer way, the statistics stored in a single db table, so it would be faster or easier to retrieve.

Examples

Lots of dashboard or reports have statistic widget like total customer, total user, total pending orders, total sales etc. For these statistic widgets we applied query across tables, rows along with mathematical equation to get the single unified numeric value. For small database the approach is ok but for large database the calculation may hamper the performance or create complexity. So what if we could calculate the statistics during the CRUD operation.

Examples 1:

Total User Counting:

Increase a user whenever a new user is store, Decrease a user whenever user delete.

Examples 2:

Total Pending Orders:

Increase or count total pending order whenever a new pending order placed, Decrease total pending order whenever an order successfully delivered.

Examples 3:

Product Stocks:

Increase product stock whenever new products purchased,

Update product stock: sometime we need to update purchase product quantity for example quantity add or subtract in the same view, in that case our product stock also need to reflect accordingly.

Decrease product stock whenever a purchase product is delete.

Get the statistics

Above examples have shown us that how we can create stats by placing increase(), decrease() inside data CRUD operations.

Now let's get or view our stats.

or

or

Installation

You can install the package via composer:

composer require radiatecode/dastats

Migrate the stats table

php artisan dastats:table

php artisan migrate

You can publish config file (optional)

php artisan vendor:publish --provider="RadiateCode\DaStats\StatsServiceProvider" --tag="dastats-config"

Usages

Stats increase:

Increase stats for given key and title.

Increase by default 1, But you can pass any specific numerical value.

Under the hood increase() check is there any stats exits for the given key & title, if yes it will increment, if not it will create new record

Stats decrease:

Decrease stats value for given key.

or

Decrease method decrease a stats by 1 (default), But you can decrease by any specific value.

Under the hood decrease() checks stats existence, if found it will decrement otherwise return null. During decrement if the decrement comes at zero it will delete the stats record from the storage.

Stats replace:

In some cases we need to replace our existing stats value in those cases replace() can be used

or

Get stats by keys

Paginate

Find single stats

or

Check stats existence

or

Get stats by contains a part of key

Remove stats:

or

Join stats

Join stats table with other db tables

joinWith()

joinWith used to join a db table with stats table

join()

join as many tables as you want like regular laravel db join

Note: get() method accept an array as an argument where it executes as db 'select' statement

Isolate stats:

Isolation can be useful for SaaS applications, certain stats can be stored for individual user or organisation or tenant.

or

Conditional operation:

or

or

Multiple increase or decrease or replace

For multiple increase or decrease we can use doMany()

when required isolation

Note: Data format should be followed as the example.

So In example 3 we see that increase operation used inside purchase products loop, but now we can use doMany() to do multiple increase by passing an array which contain product id and quantity

Jobs

Sometimes we need to queue our stats so that it can run in the background without delaying user response, so in that case we can use predefined jobs.

Note: make sure we have configured Laravel Queue and run the queue worker

Single stats job:

Multiple stats job:

or

when required isolation

DB Table Structure

Available methods

Stats can be call either by Stats Facade or new Stats() class

Here are available methods

Methods Return Note
isolate(string $name,int $id) return stats object used for stats isolation
title(string $title) return stats object set stats title
key(string $key) return stats object set stats key
contain(string $key) return stats object set part of key
increase(int value = 1) return bool increase by default 1, can be pass specific numerical value
decrease(int value = 1) return bool decrease by default 1, can be pass any numerical value
replace(int value) return bool replace existing stats value
doMany(string $action, array $data) return bool increase, decrease or replace multiple data
inKeys(...$key) return stats object find stats by multiple keys
find() return mixed or eloquent collection find specific stats
paginate(int $perPage = 10) return mixed or eloquent collection get stats by paginate
get(array $columns = []) return mixed or eloquent collection get stats data, argument used to select table columns
exists(callable $existsCallback = null,callable $notExistsCallback = null) return true/false if args empty we can apply stats operation based on exist condition by passing args, 1st arg works when stats exists, 2nd arg works when stats not exists. If no args pass then it simply return true/false.
remove() return true or false remove particular stats
when(bool $value,callable $callback,callable $default = null) return stats object conditionally apply stats operation
joinWith(string $table,string $pk = 'id') return stats object join the table with stats table
join($table, $first, $operator = null, $second = null) return stats object join more than one table with stats

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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


All versions of dastats with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-json Version *
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 radiatecode/dastats contains the following files

Loading the files please wait ...