zf2+doctrine-odm patch tools
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
library/DoctrineDbPatcher
tests
.gitignore
LICENSE
README.md
composer.json

README.md

##doctrine-db-patcher Gives your ZF2+Doctrine-Project a toolset for database-patches.

===================

###DoctrineDbPatcher

####Requirents: php >=5.4

ZF2: https://github.com/zendframework/zf2

DoctrineMongoODMModule: https://github.com/doctrine/DoctrineMongoODMModule

or

DoctrineORMModule: https://github.com/doctrine/DoctrineORMModule

####Installation via composer: add to composer.json:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Cyberrebell/doctrine-db-patcher"
        }
    ],
    "require": {
        "Cyberrebell/doctrine-db-patcher": "dev-master"
    },

####Configuration in project: add to application.config.php:

return [
    'modules' => [
        'DoctrineDbPatcher'
    ]
];

add to any module.config.php:

return [
    'DoctrineDbPatcher' => [
        'doctrine-objectmanager-service' => 'Doctrine\ODM\Mongo\DocumentManager', //or Doctrine\ORM\EntityManager
        'patches' => include 'doctrine.patches.php'
    ]
];

create doctrine.patches.php and add your patches like this:

<?php 
return [
    '1.0.0' => [
        'insert' => [
            'User\Entity\Resource' => [
                'attributes' => ['route'],
                'values' => [
                    ['login'],
                    ['logout'],
                ]
            ],
            'User\Entity\Permission' => [
                'attributes' => ['description'],
                'values' => [
                    ['Sich einloggen'],
                    ['Sich ausloggen'],
                ]
            ],
        ],
        'update' => [
             'User\Entity\Guestbook' => [
                 [
                     'attributes' => ['title'],
                     'values' => [
                         ['old' => ['This is a niec website'], 'new' => ['This is a nice website']],
                     ]
                 ],
             ],
        ],
        'delete' => [
             'User\Entity\Guestbook' => [
                 [
                     'attributes' => ['title'],
                     'values' => [
                         ['Hello everyone'],
                     ]
                 ],
             ],
        ],
        'connect' => [
            [
                'entities' => ['User\Entity\Permission' => 'User\Entity\Resource'],
                'methods' => ['addResource' => 'removeResource'],
                'targets' => [
                    ['source' => ['description' => 'Sich einloggen'], 'target' => ['route' => 'login']],
                    ['source' => ['description' => 'Sich ausloggen'], 'target' => ['route' => 'logout']],
                ]
            ]
        ]
    ]
];

####Configuration in project: run the patch-tool:

php public/index.php dbpatch