Download the PHP package avinash403/laravel-dynamic-observer without Composer

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

Laravel Dynamic Observer

In laravel or any other framework which uses eloquent for data modelling, observer is a useful feature. But performing an action on model update without registering beforehand is handy.

Laravel Dynamic Observer provides an easy way to observe your model in model itself by simply importing it in the model and defining the listener methods.

Motivation

It is real easy to create a trait yourself and use it with eloquent model events but it is not worth it in writing the same piece of code in all of your projects.Apart from this, there are cases where we need to perform same action on creation, updation and deletion of a model(for example, clearing a particular cache after a record is updated, created or deleted). In those scenarios we have an option of either writing the same piece of code in all of those event listener or make a common method and call it in all of them. The later scenario is the key motivation for making this package so that we can have a method in our model which gets called automatically as soon as any model activity(create, update or delete) happens.

Compatibility

Any project with eloquent as database model.(can be a non-laravel project)

Installation by Composer

$ composer require avinash403/laravel-dynamic-observer

Usage example

Available methods

Point to remember

Methods related to update and delete only gets called if the record is retrieved from the DB before updating or deleting. The reason is when we are using an update directly on a query, we are not actually performing any action. For eg.

here we are calling Eloquent\Builder@update not Model@update, so it just cannot call update event. Same is applicable to delete event.

But when we are doing something like this:

We exactly know which record we have fetched. In this case we have used Model@update, which will cause event to fire.

Test

Run test by simply typing

from the root directory of this package.

Contribute on github

clone this repository( https://github.com/avinash403/laravel-dynamic-observer.git ), make your changes and raise a pull request to development branch


All versions of laravel-dynamic-observer with dependencies

PHP Build Version
Package Version
No informations.
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 avinash403/laravel-dynamic-observer contains the following files

Loading the files please wait ....