Download the PHP package aaronfrancis/eventable without Composer

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

Eventable

Latest Version on Packagist Tests Total Downloads PHP Version License

A Laravel package for tracking events on Eloquent models with polymorphic relationships, backed enums, and query helpers for both individual event records and parent models.

Eventable stores both a registered enum alias in type_class and the enum backing value in type. That keeps overlapping enum values safe across multiple event enums and lets you rename enum classes without breaking historical data.

Highlights:

Installation

Publish the config and migration:

Quick Start

1. Add the trait to your models

2. Create a backed enum for your event types

The published migration uses a string column for type, so int-backed and string-backed enums both work out of the box. If you customize the migration to use an integer column, string-backed enums will no longer fit.

3. Register your enum in config/eventable.php

This registration is required. It enables:

4. Review morph key and morph map setup

The published migration uses morphs('eventable'), so it follows Laravel's default morph key type. If your app uses UUIDs or ULIDs for polymorphic keys, call Schema::morphUsingUuids() or Schema::morphUsingUlids() before running the migration.

Since Eventable uses polymorphic relationships, it is also a good idea to use Laravel's enforced morph map for your own models:

Eventable separately registers its own Event model in Laravel's morph map when eventable.register_morph_map is enabled.

Recording Events

The second argument can be an array or any JSON-serializable scalar value. Exact scalar matching works for values like false, 0, '0', and ''.

Helper Methods

latestEvent() and whereLatestEventIs() use the same definition of "latest": newest created_at, with id as the tie-breaker. Those latest-event queries also resolve through your configured Event model, so custom global scopes stay in effect.

Querying a Model's Events

Raw values only filter the type column. If multiple enums can share the same backing values, pair raw values with ofTypeClass() or use an enum case directly.

Querying Models by Event Criteria

Querying Models by Events

Pruning Old Events

Implement PruneableEvent on your registered enums to configure retention policies:

If you prefer, you can still return new PruneConfig(...) directly.

Run the prune command:

Schedule it in your routes/console.php or kernel:

PruneConfig must define at least one retention rule: before, keep, or both. Prune is a fluent builder for producing that config. When pruning by keep, Eventable keeps the newest rows by created_at desc, id desc. If varyOnData is enabled, rows are partitioned by model and canonicalized JSON payload before the keep limit is applied, so equivalent JSON objects are grouped together across supported drivers.

Custom Event Models

You can extend the default Event model:

Then update the config:

Relationships, direct Event queries, and the prune command all resolve through the configured model class.

Docs

License

MIT


All versions of eventable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/database Version ^11.0|^12.24
illuminate/support Version ^11.0|^12.24
nesbot/carbon Version ^3.0
staudenmeir/laravel-cte Version ^1.6
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 aaronfrancis/eventable contains the following files

Loading the files please wait ...