Download the PHP package yii2tech/model-change without Composer

On this page you can find all versions of the php package yii2tech/model-change. 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 model-change

Model Change Tracking Extension for Yii2


This extension provides Yii2 model data and state change tracking.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Usage

This extension provides Yii2 model data and state change tracking. It provides solution, which works around the model classes, allowing their events tracking from external, allowing enabling or disabling it at will.

Imagine following use case: we composing complex web pages, which content is based on database records. So we have an administration panel, which provides setup for particular page content parts, like 'header', 'footer' etc, as well as custom pages and main menu items. In order to keep high performance we widely use cache for different pages and page parts, avoiding regular database queries for page contents. However, once some record is changed from admin panel the cache should be invalidated, so changes may actually appear at the side. But it is not very practical to clear entire cache per each content database record change as system administrator may edit several records during single user session and only after he consider all changes are done cache should be cleared. Thus instead of clearing cache we want simply show some notification to the user at web interface, which should remind him that cache should be cleared before changes will appear at the main site.

It is not good to place such functionality inside the model classes using model events or behaviors as functionality will affect only administration panel and should not consume resources at main or console application. This means that model event handlers, which respond model saving and deletion, should be assigned dynamically from outside.

Controller Filter

The use case described above can be solved using [[\yii2tech\modelchange\ModelChangeFilter]]. As a filter it can be attached either to the controller or module (including application itself).

Controller configuration example:

Now, once app\models\Page model is saved during some PageController action run, the session flag 'cacheFlushRequired' will be set. This flag should be processed somewhere at administration page layout, like following:

Tip: in case there is modelClass property at the controller class, its value will be automatically picked up as [[\yii2tech\modelchange\ModelChangeFilter::$modelClasses]] value, so you can omit it.

The last thing to do is clearing the session flag during the related controller action:

You can also attach [[\yii2tech\modelchange\ModelChangeFilter]] to the module level or the entire application itself:

Then whenever some of the configured models are changed during some controller action, afterModelChange callback will be executed.

Instead of using [[\yii2tech\modelchange\ModelChangeFilter::$afterModelChange]] callback, you can attach an event handler for [[\yii2tech\modelchange\ModelChangeFilter::EVENT_AFTER_MODEL_CHANGE]] event at the filter owner scope. For example: you can create a following controller behavior:

Such behavior then can be attached along with [\yii2tech\modelchange\ModelChangeFilter]] one:

Creating Custom Solution

This extension provides [[\yii2tech\modelchange\ModelChangeTrait]] trait, which contains basic functionality needed for creation of your own external model change tracker. For example: you may bind such functionality directly to particular controller class instead of using filter:


All versions of model-change with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
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 yii2tech/model-change contains the following files

Loading the files please wait ....