Tutorials

Crédit photo : pxfuel.com

How to install eZ Migration Bundle on Ibexa Content 3?

on Monday 28 June 2021

Context

eZ Publish has evolved to eZ Platform and after eZ Systems corporation changes their name to Ibexa, eZ Platform has renamed to Ibexa Content.

Ibexa Content is a Hierarchical Content Management System, useful for managing large websites with many different content types.

On eZ Publish or eZ Platform 2.5, you may use the Kaliop bundle to manage the database schema and content between each server environment. This bundle allows to create, update or delete all eZ Platform structure and content. One migration is a simple SQL file or a YAML file with the instructions to migrate the database.

For Ibexa Content, the original Kaliop eZ Migration bundle does not work. Ibexa has published a compatible version with two subtilities.

Prerequisite

This guide is only for eZ Platform 3.x and Ibexa Content 3.x. Yous need to have a working project on your computer before continuing.

The dependency manager Composer must be installed. This guide supposes you have the Composer installation path into the operating system environment variable PATH.

Installation

To install the bundle, open a terminal window and navigate to your project root folder.

Now, run this command: composer require ezsystems/ezmigrationbundle

 

Create a migration bundle for your platform

The eZ Migration Bundle allows making migration only with a Bundle. It's a legacy behavior from the older Symfony version.

To solve this requirement, make a "SiteMigrationBundle" directory into the "src" directory on your project.

Add the file "SiteMigrationBundle.php" into the directory made in the previous step with this content:

   

<?php
declare(strict_types=1); 
namespace App\SiteMigrationBundle; 
use Symfony\Component\HttpKernel\Bundle\Bundle; 
final class SiteMigrationBundle extends Bundle
{ 
} 
   

Register this bundle into config/bundles.php

   

//... 
App\SiteMigrationBundle\SiteMigrationBundle::class => ['all' => true], 
//... 
   

Now you can run Kaliop's commands.

Fix a small issue

 If you try this command bin/console kaliop:migration:generate SiteMigrationBundle , you have this error:

   

In Container.php line 266: 
  The "ez_migration_bundle.helper.config.resolver" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.                                                 
kaliop:migration:generate [--format FORMAT] [--type TYPE] [--mode MODE] [--match-type MATCH-TYPE] [--match-value MATCH-VALUE] [--match-except] [-l|--lang LANG] [--dbserver DBSERVER] [-a|--admin-login ADMIN-LOGIN] [--list-types] [--siteaccess [SITEACCESS]] [--] [<bundle> [<name>]]
  
   

To solve this issue before the new version with the fix is available, add this service configuration in your service file "config/services.yaml":

   

    ez_migration_bundle.helper.config.resolver:
        public: true
        class: '%ez_migration_bundle.helper.config.resolver%'
        arguments:
            - '@ezpublish.config.resolver'
            - '@service_container' 
   

Enjoy!

Now you can use this bundle when you use the Kaliop migration bundle on your Ibexa Content platform.

For example, this command generates a YAML migration for add the Administrator role:

   

$ bin/console kaliop:migration:generate --type=role --mode=create --match-type=identifier --match-value=Administrator SiteMigrationBundle 
Generated new migration file: /var/www/ibexa_website/src/SiteMigrationBundle/MigrationVersions/20210618122305_placeholder.yml 
   

All your generated migrations will be stored into "src/SiteMigrationBundle/MigrationVersions/ "