Skip to content

phpcr/phpcr-migrations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPCR Migrations

Build Status

Migrations library for PHPCR influenced by Doctrine migrations.

For integration with Symfony see the PHPCR Migrations Bundle.

Usage

<?php

use Symfony\Component\Console\Output\NullOutput;
use PHPCR\Migrations\VersionStorage;
use PHPCR\Migrations\VersionFinder;
use PHPCR\Migrations\Migrator;

$storage = new VersionStorage($phpcrSession);
$finder = new VersionFinder(array('/path/to/migrations'));

$versions = $finder->getVersionCollection();
$migrator = new Migrator($session, $versionCollection, $storage);

$to = '201504241744';
$output = new NullOutput();
$migrator->migrate($to, $output);

Versions

Version classes contain up and down methods. The class is quite simple:

<?php

use PHPCR\Migrations\VersionInterface;

class Version201504241200 implements VersionInterface
{
    public function up(SessionInterface $session)
    {
        $session->doSomething();
    }

    public function down(SessionInterface $session)
    {
        $session->undoSomething();
    }
}

They must be named VersionYYYMMDDHHMM. If they are not so named, then they will not be detected.

About

PHPCR Migrations library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

Languages