2017 © Pedro PelĆ”ez
 

library object-migration

Migrations between object versions, configurable via annotations.

image

evispa/object-migration

Migrations between object versions, configurable via annotations.

  • Friday, September 13, 2013
  • by nercury
  • Repository
  • 6 Watchers
  • 2 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Object migration library

Build Status: Build Status, (*1)

Overview

Migrate objects to different versions based on version annotations., (*2)

For example, let's say we have two class versions, the second one modifies public field name from "slug" to "id":, (*3)

class V1
{
    public $slug;
}

class V2
{
    public $id;
}

We can then decorate these classes with version annotations, and create migration method to the new version:, (*4)

use Evispa\ObjectMigration\Annotations as Api;

/**
 * @Api\Version("object.v1")
 */
class V1
{
    public $slug;
}

/**
 * @Api\Version("object.v2")
 */
class V2
{
    public $id;

    /**
     * @Api\Migration(from="V1")
     */
    public static function fromV1(V1 $other, $options) {
        $obj = new self();

        $obj->id = $other->slug;

        return $obj;
    }
}

Use VersionConverter tool to check object version or migrate object to another available version:, (*5)


use Doctrine\Common\Annotations\AnnotationReader; use Evispa\ObjectMigration\VersionReader; use Evispa\ObjectMigration\VersionConverter; $converter = new VersionConverter(new VersionReader(new AnnotationReader()), 'V2'); // create v1 object $v1 = new V1(); $v1->slug = "TEST"; // migrate to another version $v2 = $converter->migrateFrom($v1); $this->assertTrue($v2 instanceof V2); // true $this->assertEquals("TEST", $v2->id); // true

Requirements

This library will use: * doctrine/annotations for annotation parsing * clue/graph for version migrations search, (*6)

Installation

This library can be easily installed via composer, (*7)

composer require evispa/object-migration

or just add it to your composer.json file directly., (*8)

The Versions

13/09 2013

dev-master

9999999-dev

Migrations between object versions, configurable via annotations.

  Sources   Download

MIT

The Requires

 

by Nerijus Arlauskas
by Darius KriŔtapavičius