2017 © Pedro Peláez
 

library phpcr-migrations

Migrations for PHPCR

image

phpcr/phpcr-migrations

Migrations for PHPCR

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 13 % Grown

The README.md

PHPCR Migrations

Build
Status, (*1)

Migrations library for PHPCR influenced by Doctrine migrations., (*2)

For integration with Symfony see the PHPCR Migrations Bundle., (*3)

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(['/path/to/migrations']);

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

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

You may also create a factory class (useful when you use dependency injection):, (*4)

<?php

$factory = new MigratorFactory($storage, $finder, $session);
$migrator = $factory->getMigrator();

Initializing

When you install a project for the first time you need to initialize the versions:, (*5)

<?php

$migrator->initialize();

This should be part of your build process and it will add all the versions to the migration version node in the content repository., (*6)

Migrating

```php $migrator->migrate('201501011200', $output); // migrate to a specific version $migrator->migrate('up', $output); // migrate up a version $migrator->migrate('down', $output); // migrate down a version $migrator->migrate('top', $output); // migrate to the latest version $migrator->migrate('bottom', $output); // revert all versions, (*7)


### Listing versions You can access information about available versions from the `VersionCollection` object: ````php $versionCollection->getAllVersions();

Determining the current version

You can determine the current version from the VersionStorage object:, (*8)

$versionStroage->getCurrentVersion();

Version classes

Version classes contain up and down methods. The class is quite simple:, (*9)

<?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., (*10)

The down method should revert any changes made in the up method. Always check that revcerting your migration works., (*11)

The Versions

05/12 2016
05/12 2016

dev-finder_error

dev-finder_error

Migrations for PHPCR

  Sources   Download

MIT

The Requires

 

The Development Requires

04/02 2016

0.1.1

0.1.1.0

Migrations for PHPCR

  Sources   Download

MIT

The Requires

 

The Development Requires

29/04 2015

0.1

0.1.0.0

Migrations for PHPCR

  Sources   Download

MIT

The Requires

 

The Development Requires