Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpcr Migrations Bundle Laravel Package

dantleech/phpcr-migrations-bundle

Archived Symfony bundle integrating PHPCR migrations (renamed to phpcr/phpcr-migrations-bundle). Configure migration paths or auto-discover in bundle Resources, create VersionYYYYMMDDHHSS classes, and run console commands to check status and migrate.

View on GitHub
Deep Wiki
Context7

PHPCR Migrations Bundle

This library provides a Symfony integration for the PHPCR migrations library.

This version has been archived

This bundle has been renamed to phpcr/phpcr-migrations-bundle. We recommend to update your dependencies to get the latest version.

dantleech/phpcr-migrations-bundle will remain available to not break existing installations, but is no longer maintained.

Configuration

Configure the path to your migrations:

# app/config.yml
phpcr_migrations:
    paths: [%kernel.root_dir%/phpcr-migrations]

Or the bundle will automatically pick up any migrations in the Resources/phpcr-migrations folder in any bundles registered in the kernel.

Creating migrations

First create two new migration files:

<?php
// app/phpcr-migrations/Version201501011200.php

use PHPCR\SessionInterface;
use PHPCR\Migrations\VersionInterface;

class Version201501011200 implements VersionInterface
{
    public function up(SessionInterface $session)
    {
        $session->getRootNode()->addNode('hello');
    }

    public function down(SessionInterface $session)
    {
        $session->getRootNode()->getNode('hello')->remove();
    }
}

and

<?php
// app/phpcr-migrations/Version201501011212.php

use PHPCR\SessionInterface;
use PHPCR\Migrations\VersionInterface;

class Version201501011212 implements VersionInterface
{
    public function up(SessionInterface $session)
    {
        $session->getNode('/hello')->addNode('world');
    }

    public function down(SessionInterface $session)
    {
        $session->getNode('/hello')->getNode('world')->remove();
    }
}

Migration status

Note that migration MUST be named as follows: VersionYYYMMDDHHSS. If they are not so-named, they will not be detected. The timestamp SHOULD be the current date (in this example 2015/01/01 12:00).

Now execute the phpcr:migrations:status command:

$ php app/console phpcr:migrations:status
+--+---------------+------------------+----------+----------------------------------------------+
|  | Version       | Date             | Migrated | Path                                         |
+--+---------------+------------------+----------+----------------------------------------------+
|  | 201501011200 | 2015-01-01 12:00 | NO       | app/phpcr-migrations/Version201501011200.php |
|  | 201501011212 | 2015-01-01 12:12 | NO       | app/phpcr-migrations/Version201501011212.php |
+--+---------------+------------------+----------+----------------------------------------------+
No migrations have been executed

Executing migrations

Now we can run the migrations:

$ php app/console phpcr:migrations:migrate
Upgrading 2 version(s):
 + [1/2]: 201501011200
 + [2/2]: 201501011212

This should run the two migrations, your status should not look like this:

Reverting

You can now revert back to the first version as follows:

$ php app/console phpcr:migrations:migrate 201501011200
Reverting 1 version(s):
 - [1/4]: V201501011212

Actions

In addition to specifying versions you can specify actions:

$ php app/console phpcr:migrations:migrate up
Upgrading 1 version(s):
 - [1/4]: V201501011212

Actions are:

  • up: Upgrade one version
  • down: Revert one version
  • top: Migrate to the latest version
  • bottom: Revert all migrations
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums