Download the PHP package mima/doctrine-entity-changes without Composer

On this page you can find all versions of the php package mima/doctrine-entity-changes. 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 doctrine-entity-changes

Doctrine Entity Changes

Build Status

Library makes it easy to get changes of Doctrine entities.

Installation

Run command:

Add dependency to your composer.json:

How to use

Note that getting changes must be earlier then flush. For example, declare entity class:

Simple way to get changes

If field is part of association, then $fullName equals to .. If field is part or root object, then $fullName equals to $name. Old and New value converted from DateTime, Boolean, Integer and another fields by rules described above.

Convert dates to string

By default used this formats:

You cat declare custom formats in first argument of ProcessorFieldVisitorFactory:

Convert booleans to string

By default boolean converts to this strings:

You can declare custom rules in second argument of ProcessorFieldVisitorFactory:

Convert floats to string

Float always converted to string accurate to 2 digits after the dot.

Convert entities to string

Entity field values presents as serialized array:

You can use this fields for fetching entity.

Collect changes

Collect changes for example entity:

`

Field iteration

Field iteration is implemented using visitors. For example make ChangeLog entity

To simplify you can extend you visitor of:

  1. \Doctrine\ORM\ChangeSet\Visitor\AbstractEmptyFieldVisitor - full clear field visitor (with empty methods)
  2. \Doctrine\ORM\ChangeSet\Visitor\AbstractCommonFieldVisitor - visitor with logic to "pre-formatting" fields, like in example above

Otherwise you can implement \Doctrine\ORM\ChangeSetFieldVisitorInterface. For certain tasks you can use \Doctrine\ORM\ChangeSet\Visitor\CallbackFieldVisitor

Abstract visitors

Let's try to implement simple EntityFieldVisitor with AbstractCommonFieldVisitor:

You can add list of accepted fields in third argument of parent class constructor. By default accepted all fields. Example of saving received logs:

Visitor with callback

Callback visitor allows you to walk through field changes with a specific type.

Full implementation of visitor

Further you need it's implement FieldVisitorInterface:

Getting field name

For getting field name relative to the class where the field is declared all of you need:

This code return convrete field name: title, createdAt, etc. For getting full path of field, relative to root class in a chain to relations, need to do the following:

This code return field name like: relation.subRelation.title

Getting relation changes

The visitor enters only fields. You can getting relations changes through call:

As another way you can apply visitor to concrete related change set:

In this case relatedFieldName is name of field for which the association is declared. You can get access to any relation level: relatedFieldName.subRelatedField

Apply visitor to concrete field

You can apply visitor to conreate field:

In this case fieldName is name of target field. You can get access to field in related changes:

How to help

  1. Improve README
  2. Fix text in README (My English is poor)
  3. Improve library: any suggestions, corrections are accepted

All versions of doctrine-entity-changes with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
doctrine/orm Version 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 mima/doctrine-entity-changes contains the following files

Loading the files please wait ....