Download the PHP package codekanzlei/cake-model-history without Composer

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

CakePHP 3 Model History Plugin

Build Status codecov

CakePHP 3 Historization for database records. Keeps track of changes performed by users and provides a customizable view element for displaying them.

Requirements

Installation

1. require the plugin in your composer.json

Open a terminal in your project-folder and run these commands:

`$ composer update`

2. Configure config/bootstrap.php

Load the Plugin:

Since all changes to a record are saved to the field data (type MEDIUMBLOB) in the ModelHistoryTable in JSON format, you must use custom Type Mapping.

3. Create a table model_history in your project database

We have to create the database schema with help of the migrations plugin.

4. AppController.php

$helpers

Usage & Configuration:

Table setup

Add the Historizable Behavior in the initialize function of the Table you want to use model-history.

Note: By default, the model-history plugin attributes changes to a database record to the user that performed and saved them by comparing table-fields 'firstname' and 'lastname' in UsersTable (See $_defaultConfig in HistorizableBehavior.php for these default settings). If your fields are not called 'firstname' and 'lastname', you can easily customize these settings according to the fieldnames in your UsersTable, like so:

By default, the ModelHistory monitors changes for every field it finds in the schema of the table. It tries to deduct the type to use from the data type and obfuscates all fields containing "password". Otherwise, the default values are 'searchable' => true, 'saveable' => true and 'obfuscated' => false.

To override specific settings, add an array for the field into the 'fields' array and list the values you want to override.

Because the default monitored fields are limited to those in the table, n:m associations and associations with foreign_keys in other tables always have to be configured, at least with the type. Here are three real world examples from a UsersTable:

Types:

The three types relation, association and mass_association are able to link to associated entities. The url defaults to:

The default url can be overwritten: url in the behavior-array overwrites default and the defined url in the field-config has the highest priority.

If saved association's entries shall be viewed within the source entities entries, you can specify the associations key. It has to match the object property keys given in the source entity. Furthermore the model history area has to get the option includeAssociated with value true.

To further specify the context in which the entity was saved and in order to gather additional information, you can implement \ModelHistory\Model\Entity\HistoryContextTrait inside your entity. You have to call setHistoryContext on the entity to add the context information. Currently there are three context types: ModelHistory::CONTEXT_TYPE_CONTROLLER, ModelHistory::CONTEXT_TYPE_SHELL and ModelHistory::CONTEXT_TYPE_SLUG. The optional slug gets translated automatically, when its defined in the entities typeDescriptions.

You can also specify a context getter inside an entity to search for defined contexts. Please keep in mind that you have to use the TypeAwareTrait from the CkTools:

Ignoring fields

By default, the fields id, created and modified are not tracked. If you want to overwrite which fields are ignored or not, give ignoreFields in the config array and only those fields will be ignored:

View setup

Use ModelHistoryHelper.php to create neat view elements containing a record's change history with one call in your view:

modelHistoryArea has the following Options:

For the modelHistoryArea to fetch its data, add the 'ModelHistory' component to the baseComponents property in your Frontend.AppController under /webroot/js/app/app_controller.js. If you haven't set up the FrontendBridge yet, follow these steps. There you will also find a template for this file.

Make sure app_controller.js is loaded on the page where you want to show the modelHistoryArea. Then the ModelHistory JS-Component will make AJAX requests to /model_history/ModelHistory/index/$modelName/$primaryKey according to the $entity you gave the helper method and populate the modelHistoryArea by itself.


All versions of cake-model-history with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
codekanzlei/cake-cktools Version ^1.3
codekanzlei/cake-frontend-bridge Version ^1.2
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 codekanzlei/cake-model-history contains the following files

Loading the files please wait ....