Download the PHP package webpatser/resonate-channel-meter without Composer

On this page you can find all versions of the php package webpatser/resonate-channel-meter. 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 resonate-channel-meter

Resonate Channel Meter

A Laravel package that records billable and observable channel occupancy periods from webpatser/resonate-webhooks events. It turns "this room was occupied for 12 minutes" from a polling problem into a Pusher webhook your backend just reacts to.

It is a webhook consumer, not a Resonate plugin. It runs in your Laravel app.

Where it fits

The roster makes occupancy cluster-correct. The webhooks plugin pushes the edges out as signed HTTP POSTs. This package receives them and stores them as durable periods you can query and bill on.

How it works

One period per occupancy

A channel_occupied event opens a channel_meter_periods row with started_at = time_ms and ended_at = null. The matching channel_vacated closes it. Both are idempotent: a redelivered webhook never duplicates a period or leaves an orphan close.

Channel to model resolution

The channel_meter_periods table carries a polymorphic model_type / model_id. A small resolver maps a channel name to the domain entity it represents, using a {id} placeholder:

presence-chat.42 resolves to (Chat::class, '42'), and the period is stored with that link. A channel that matches no pattern is still recorded with the channel name; it just has no model attached. Swap the default ConfigChannelResolver for your own by binding ChannelResolver::class in a service provider if you need richer rules (tenants, composite keys, lookups).

Models pull their own periods

Apply the HasChannelMeter trait to any model the resolver maps to:

You get:

Installation

The package migration is auto-loaded. Run it:

Publish the config to register channel patterns:

Registering the webhook endpoint

The package does not auto-register a route, so you mount the controller wherever you want, behind the signature middleware:

Then point the webhooks plugin at that URL:

The middleware verifies the X-Pusher-Signature against the app secret in reverb.apps, so an unsigned or forged request is rejected with 401. An unknown X-Pusher-Key is rejected with 422.

Fully-occupied metering (min members + grace)

By default a period spans plain room occupancy: channel_occupied opens it, channel_vacated closes it. Set min_members to 2 (or more) to meter only while the channel is fully occupied, for example billing a two-party reading only while both the customer and the consultant are present.

In this mode every membership event re-evaluates the live member count, so the package needs a way to read it. Bind a MembershipCounter; the shipped NullMembershipCounter always returns 0, so a host that uses webpatser/resonate-roster typically binds a small adapter over its roster:

grace_seconds keeps the period open for a window after the count drops below the threshold, closing it at dropped-below + grace only if the count does not recover (it absorbs brief reconnects). Because a channel can simply go quiet after dropping below, schedule the backstop sweep:

For a live in-progress meter, read the open period plus the metadata.below_since marker yourself and cap billable time at below_since + grace; the sweep then persists the same close durably.

Configuration reference

Key Default Purpose
patterns [] Channel-to-model patterns. Each maps a channel-name shape with a {id} placeholder to an Eloquent model class.
min_members 1 Members required to keep a period open. <= 1 is room occupancy; >= 2 is fully-occupied metering driven by the MembershipCounter.
ignore_channel_prefixes ['#'] Channel prefixes never metered. The protocol reserves # for channels the server owns, such as the #server-to-user-{id} channels webpatser/resonate-users creates; a channel matching no pattern is still recorded, so without this a sign-in would open a billable period.
grace_seconds 0 How long an open period survives below the threshold before closing at dropped-below + grace.

Notes and caveats

Requirements

Testing

License

MIT. See LICENSE.


All versions of resonate-channel-meter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
illuminate/contracts Version ^13.0
illuminate/database Version ^13.0
illuminate/http Version ^13.0
illuminate/routing Version ^13.0
illuminate/support Version ^13.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 webpatser/resonate-channel-meter contains the following files

Loading the files please wait ...