Download the PHP package ameax/laravel-hash-change-detector without Composer

On this page you can find all versions of the php package ameax/laravel-hash-change-detector. 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 laravel-hash-change-detector

Laravel Hash Change Detector

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Detect changes in your Laravel models through hash-based tracking and automatically publish updates to external systems. Perfect for maintaining data synchronization across multiple platforms, APIs, or services.

Key Features:

Table of Contents

Installation

Publish and run migrations:

Optionally publish the config:

Optional: API Documentation with Swagger

If you want to use the included API controllers with automatic Swagger documentation:

The API controllers include comprehensive OpenAPI attributes for automatic documentation generation with l5-swagger. See Swagger Integration Guide for details.

Quick Start

1. Make Your Model Hashable

That's it! Your model now automatically:

Basic Usage

Making a Model Hashable

To track changes in a model, implement the Hashable interface and use the InteractsWithHashes trait:

Tracking Related Models

When you have parent-child relationships, the child models should also be hashable and define their parent relationships:

How It Works

  1. Individual Hashes: Each model has its own hash based on getHashableAttributes()
  2. Composite Hashes: Parent models also have a composite hash that includes hashes from all tracked relations
  3. Automatic Updates: When a child changes, it notifies its parents to recalculate their composite hashes
  4. Event Driven: All updates trigger events that you can listen to

Model Types and Detection Strategies

The package supports two types of models, each with different use cases:

1. Regular Models (Two-Way Sync)

Standard Eloquent models that can be modified both through Laravel AND external systems:

When to use:

Features:

2. Read-Only Models (One-Way Sync)

Models that are NEVER modified through Laravel, only tracked for external changes:

When to use:

Features:

Choosing the Right Approach

Scenario Model Type Why
Products with admin panel Regular + Detection Need Eloquent updates + external sync
Database view of sales Read-Only + Detection Can't update views via Eloquent
User accounts Regular + Detection App updates + admin tools
External inventory table Read-Only + Detection Managed by warehouse system
Orders with API imports Regular + Detection Create via app + import via API
Analytics aggregates Read-Only + Detection Updated by SQL procedures

Direct Database Detection

Direct database detection finds changes made outside of Laravel (SQL updates, triggers, external apps, etc.).

Setting Up Detection

Add to your scheduler in app/Console/Kernel.php:

How Direct Detection Works

  1. Calculates hashes in the database using SQL functions
  2. Compares with stored hashes to find changes
  3. Updates changed records and triggers events
  4. Detects deletions by finding orphaned hash records

Example Scenario

Publishing System

Automatically sync changes to external systems by creating publishers:

Creating a Publisher

Registering Publishers

In a service provider:

Or via command:

Retry Failed Publishes

Add to your scheduler:

Advanced Usage

Working with Read-Only Models

For read-only models (see Model Types above), you need to initialize hashes since there are no Eloquent events:

Then use normal detection:

Mixed Model Environment

You can use both model types in the same application:

Nested Relations

Track nested relationships using dot notation:

Multiple Parents

A model can notify multiple parent models:

Custom Hash Algorithm

In your config file:

Syncing from External APIs

When receiving data from external APIs, you can update models without triggering publishers:

Key Features:

Handling Deletions

Listen for deletion events:

Commands

Complete Example

Here's a full example with Order and OrderItem models:

API Endpoints

The package provides a comprehensive REST API for managing hash detection and publishing:

Setup

Include the API routes in your application:

Available Endpoints

Model Hash Information

Force Publish (Without Hash Change)

Publish History

Publisher Management

Operations

Statistics

API Usage Examples

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email the maintainers directly instead of using the issue tracker.

Credits

License

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


All versions of laravel-hash-change-detector with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.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 ameax/laravel-hash-change-detector contains the following files

Loading the files please wait ....