Download the PHP package zackaj/laravel-debounce without Composer

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

logo

Laravel debounce

by zackaj

Laravel-debounce allows you to accumulate / debounce a job, notification or command to avoid spamming your users and your app's queue.

It also tracks and registers every request occurrence and gives you a nice report tracking with information like ip address and authenticated user per request.

Table of Contents

Introduction

This laravel package uses UniqueJobs (atomic locks) and caching to run only one instance of a task in a debounced interval of x seconds delay.

Everytime a new activity is recorded (occurrence), the execution is delayed by x seconds.

Features

[!WARNING] Debouncing artisan commands requires laravel version >=11

Demo

A debounced notification to bulk notify users about new uploaded files.

https://github.com/user-attachments/assets/b1d5aafd-256d-4f6f-b31a-0d6dc516793b

See Code FileUploaded.php DemoController.php

Installation

Prerequisites

Composer

Configuration

Optionally publish the config file:

This will publish config/debounce.php:

You can also toggle debouncing via your .env file:

This is useful for local development or testing environments where you want to disable debouncing without changing any code.

Usage

Basic usage

You can debounce existing jobs, notifications and commands with zero setup.

[!NOTE] you can't access Advanced usage.

Advanced usage

In order to use:

your existing jobs, notifications and commands must extend:

or just generate new ones using the available make commands.

Make commands

No facade usage

Alternatively, now you can debounce from the job, notification and command instances directly without using the Debounce facade used in Basic usage

Report Tracking

Laravel-debounce uses the cache to store every request occurrence, use getReport() method within your debounceables to access the report chain that has a collection of occurrences.

Every report will have one occurrence minimum.

Before After Hooks

If you wish to run some code before and/or after firing the debounceables you can use the available hooks.

Important: after() hook could run before your debounceable is handled if it's sent to the queue when:

see: Basic usage

Debounce job

Debounce notification

You get the $notifiables injected into the hooks.

Debounce command

Due to limitations, the hook methods must be static.

Override Timestamp

By default laravel-debounce debounces from the last occurrence happenedAt timestamp

You can override this method in your debounceables in order to debounce from a custom timestamp of your choice. If null is returned the debouncer will fallback to the default implementation above.

Debounce job

Debounce notification

You get the $notifiables injected into the method.

Debounce command

Due to limitations, the method must be static.

Bonus CLI Debounce ( Laravel version >= 11.0.0 )

For fun, you can actually debounce commands from the CLI using the debounce:command Artisan command.

here's the signature for the command: php artisan debounce:command {delay} {uniqueKey} {signature*}

Debugging And Monitoring

I recommend using Laravel telescope to see the debouncer live in the queues tab and to debug any failures.

Testing

When running tests, you may want to disable debouncing so jobs, notifications and commands are fired immediately without any debounce logic.

Add this to your phpunit.xml or .env.testing:

Or disable it per test:

Known Issues

1- If you clear / flush the cache, the report tracking and the registered dispatches will be lost.

2- Debouncing artisan commands requires laravel version >=11

Contributing

Contributions, issues and suggestions are always welcome! See contributing.md for ways to get started.

License

MIT


All versions of laravel-debounce with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10.0|^11.0|^12.0|^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 zackaj/laravel-debounce contains the following files

Loading the files please wait ...