PHPackages                             monooso/unobserve - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. monooso/unobserve

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

monooso/unobserve
=================

Mute and unmute Laravel observers at will.

v7.0.0(1mo ago)83407.1k↓46.5%12[1 PRs](https://github.com/monooso/unobserve/pulls)MITPHPPHP ^8.3CI passing

Since Sep 25Pushed 3w ago2 watchersCompare

[ Source](https://github.com/monooso/unobserve)[ Packagist](https://packagist.org/packages/monooso/unobserve)[ Docs](https://github.com/monooso/unobserve)[ RSS](/packages/monooso-unobserve/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (10)Versions (22)Used By (0)

Unobserve
=========

[](#unobserve)

 [![Lint and Test Status](https://github.com/monooso/unobserve/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/monooso/unobserve/actions/workflows/lint-and-test.yml) [![Latest Stable Version](https://camo.githubusercontent.com/254b7c744611c468e0fdd5c9ddcd623d3e7ff2b66165374b13e903f33125df72/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6f6f736f2f756e6f6273657276652f762f737461626c652e737667)](https://packagist.org/packages/monooso/unobserve) [![License](https://camo.githubusercontent.com/0a9e30062b55276fac076d67823df0df085cbe0816eaf8079fa9905390d4f479/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6e6f6f736f2f756e6f6273657276652f6c6963656e73652e737667)](https://packagist.org/packages/monooso/unobserve)

About Unobserve
---------------

[](#about-unobserve)

When testing Laravel applications, we frequently need to "silence" events, so as not to trigger additional side-effects. [Laravel's `Event::fake` method](https://laravel.com/docs/mocking#event-fake) is useful, but muting a specific [model observer](https://laravel.com/docs/eloquent#observers) is still problematic.

Unobserve takes care of that, making it easy to mute and unmute an observer at will.

Requirements and installation
-----------------------------

[](#requirements-and-installation)

Unobserve supports only the latest major version of [Laravel](https://laravel.com/). See [`composer.json`](composer.json) for the exact version requirements.

Install it using [Composer](https://getcomposer.org/):

```
composer require monooso/unobserve
```

Usage
-----

[](#usage)

First, add the `CanMute` trait to your observer class.

```
