Download the PHP package stayallive/laravel-eloquent-observable without Composer
On this page you can find all versions of the php package stayallive/laravel-eloquent-observable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stayallive/laravel-eloquent-observable
More information about stayallive/laravel-eloquent-observable
Files in stayallive/laravel-eloquent-observable
Package laravel-eloquent-observable
Short Description Register Eloquent model event listeners just-in-time directly from the model.
License MIT
Homepage https://github.com/stayallive/laravel-eloquent-observable
Informations about the package laravel-eloquent-observable
Laravel Eloquent Observable
Register Eloquent model event listeners just-in-time directly from the model.
Using Observers can introduce a (significant) overhead on the application since they are usually registered in a service provider which results in every model in your application with a observer is "booted" a startup of the application even though the model is never touched in the request. This package aims to reduce that overhead by connecting listeners just-in-time whenever the Eloquent model is booted (first used) in the request. The event callbacks are also defined on the model itself keeping the code cleaner, althought this is my preference of course and if you disagree this might not be the package for you.
[!NOTE] Laravel 10.44 introduced the
ObservedBy
attribute which allows you to define the observer on the model itself which negates all the performance benefits of this package. However this package still provides an alternative way to define the event handler methods on the model itself so might still be considered useful but using theObservedBy
attribute will solve the performance issue with registering the model observers inside a service provider.
Installation
Usage
Adding the Observable
trait will ensure that the observable events are connected to the event handlers defined on the model.
Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to Alex Bouma at [email protected]
. All security vulnerabilities will be swiftly
addressed.
License
This package is open-sourced software licensed under the MIT license.