2017 © Pedro Peláez
 

yii2-extension yii2-changelog

Active record changelog extension for Yii 2 framework

image

rmrevin/yii2-changelog

Active record changelog extension for Yii 2 framework

  • Tuesday, December 19, 2017
  • by rmrevin
  • Repository
  • 3 Watchers
  • 9 Stars
  • 156 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 2 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

Active record changelog extension for Yii 2 framework

This extension provides a changelog functional., (*1)

For license information check the LICENSE-file., (*2)

Support

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

composer require "rmrevin/yii2-changelog:~1.0"

or add, (*5)

"rmrevin/yii2-changelog": "~1.0",

to the require section of your composer.json file., (*6)

Execute migrations:, (*7)

php yii migrate --migrationPath=@rmrevin/yii/changelog/migrations

Usage

To view the history, you can use a special panel for debug. Or make your own section to view the data in your administration panel., (*8)

To enable the debug panel, add the following code in the module configuration debug., (*9)

    'modules' => [
        // ...
        'debug' => [
            'class' => yii\debug\Module::className(),
            'panels' => [
                rmrevin\yii\changelog\debug\panels\ChangelogPanel::class,
            ],
        ],
    ],

For ActiveRecord models for which you want to track changes, you must implement the interface rmrevin\yii\changelog\interfaces\LoggableInterface and add the behavior of rmrevin\yii\changelog\behaviors\ChangelogBehavior., (*10)

Example:, (*11)

<?php

use rmrevin\yii\changelog\interfaces\LoggableInterface;
use rmrevin\yii\changelog\behaviors\ChangelogBehavior;
use yii\db\ActiveRecord;

/**
 * Class ShopItem
 *
 * @property integer $id
 * @property integer $number
 * @property string $title
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $synchronized_at
 */
class ShopItem extends ActiveRecord implements LoggableInterface
{

    /**
     * @inheritdoc
     */
    public function __toString()
    {
        return sprintf('[%s] %s', $this->number, $this->title);
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            // ...
            [
                'class' => ChangelogBehavior::class,
                'ignoreAttributes' => [ // these attributes are not tracked
                    'updated_at',
                    'synchronized_at',
                ],
            ],
        ];
    }
}

Done

Now when you try to create, modify or delete an instance of a model ShopItem in the table {{%changelog}} will be recorded relevant information., (*12)

The Versions

19/12 2017

dev-master

9999999-dev

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

05/10 2016

1.0.1

1.0.1.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

14/07 2016

1.0.0

1.0.0.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

01/06 2016

0.1.4

0.1.4.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

01/06 2016

0.1.3

0.1.3.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

21/04 2016

0.1.2

0.1.2.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

28/12 2015

0.1.1

0.1.1.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog

28/12 2015

0.1.0

0.1.0.0

Active record changelog extension for Yii 2 framework

  Sources   Download

MIT

The Requires

 

The Development Requires

yii activerecord history changelog