Download the PHP package akaunting/laravel-mutable-observer without Composer

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

Mutable Observer Package for Laravel

Latest Version on Packagist Total Downloads Tests Code Quality codecov StyleCI

This package allows you to mute and unmute specific observer events at will. It ships with a trait that adds mutable methods to your observer classes, making it perfect for testing scenarios and preventing unwanted side effects.

Features

Installation

Run the following command:

Usage

Basic Setup

Add the Mutable trait to your observer class:

Muting All Events

Perfect for testing scenarios where you want to disable all observer actions:

Muting Specific Events

Target individual observer methods while keeping others active:

Muting Multiple Events

Real-World Examples

Testing Scenario

Bulk Operations

Conditional Muting

Using Constants

API Reference

Mutable::mute($events = null)

Mutes the specified observer events.

Parameters:

Returns: void

Examples:

Mutable::unmute()

Unmutes all previously muted observer events.

Returns: void

Example:

Mutable::WILDCARD_EVENT

A constant representing the wildcard event that mutes all observer methods.

Value: '*'

Requirements

Code Quality

This package maintains the highest code quality standards:

Running Quality Checks

How It Works

The package uses a proxy pattern to intercept calls to your observer methods. When you call mute(), it registers a proxy in Laravel's service container that swallows the specified events. When you call unmute(), it removes the proxy and restores normal observer functionality.

Best Practices

  1. Always unmute after muting - Especially in tests, use try-finally blocks:

  2. Use setUp and tearDown in tests:

  3. Be specific when possible - Mute only the events you need to disable:

  4. Document muted events - Add comments explaining why observers are muted:

Troubleshooting

Q: Observer still firing after muting?
A: Make sure the observer is registered through Laravel's observer system and the trait is properly imported.

Q: Can I mute observers globally?
A: Yes, mute them in a service provider's boot() method or middleware.

Q: Does this work with model events?
A: Yes, it works with any observer registered via Model::observe().

Changelog

Please see Releases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-mutable-observer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3|^8.4
laravel/framework Version ^9.0|^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 akaunting/laravel-mutable-observer contains the following files

Loading the files please wait ...