1. Go to this page and download the library: Download phpcr/phpcr-migrations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpcr / phpcr-migrations example snippets
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);
$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
$versionCollection->getAllVersions();
$versionStroage->getCurrentVersion();
use PHPCR\Migrations\VersionInterface;
class Version201504241200 implements VersionInterface
{
public function up(SessionInterface $session)
{
$session->doSomething();
}
public function down(SessionInterface $session)
{
$session->undoSomething();
}
}
`
$factory = new MigratorFactory($storage, $finder, $session);
$migrator = $factory->getMigrator();
`
$migrator->initialize();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.