Download the PHP package sunlab/wn-measures-plugin without Composer

On this page you can find all versions of the php package sunlab/wn-measures-plugin. 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 wn-measures-plugin

Measures

This plugin allows you to create, update and display any measures you want on a model, some examples could be:

This plugin is intended to be used in more complex plugins or as is to register some statistics over your website's events.

Measurable Behavior

You can add the Measurable Behavior (think of it as a Trait) to any model you want. Using Storm Extension.

Extending existing models from a Plugin registration file:

Or directly to your Plugin's model:

[Experimental feature] Plugin's native and generic event listener

For the most basic events, you won't even need to write a line of code. This plugin creates a generic event listener which can handle the most basics use cases. Example here, it will listen for all the model.afterCreate event over the Winter\Forum\Models\Topic and increment a topic_created measure on the logged-in user. image

Create/Increment a measure

Once you've added the Measurable Behavior to a model, you can use the model's method incrementMeasure.

Note: You don't have to process any kind of initialization of the measure, just use it.

Practical example 1, count how many times a user edit his posts

Practical example 2, creating a post views in Winter.Blog:

Bulk incrementation

You can increment multiple models measure at once, this is useful when you want to measure the amount of models fetches from an API.

To use Bulk incrementation, you need to pass a Builder instance of your query to the MeasureManager:

Orphan measures

For some reason, you may want to increment some orphan measures:

Decrement or reset a measure

The plugin support both decrement and reset on measures, related to model or orphan measure:

Displaying a measure

To display the measure from a model, just use the getMeasure or getAmountOf methods on it. getMeasure returns a Measure model which contains an amount property

Events

As said earlier, this plugin gets really powerful and handy to use in other plugins. Events are fired on increment, decrement and reset measures. All the events contains the model (null for orphan measures), the measure object at its new state, and the amount. As an example, you can take a look into SunLab/Gamification for a full example:

MeasureManager and models

The MeasureManager static class handles orphan and bulk measures modification, but can also increment model measure:

TODO-List:

In a near future, I'll add some feature such as:


All versions of wn-measures-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
composer/installers 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 sunlab/wn-measures-plugin contains the following files

Loading the files please wait ....