承接 dennispansegrau/pimcore-content-migration-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dennispansegrau/pimcore-content-migration-bundle

Composer 安装命令:

composer require dennispansegrau/pimcore-content-migration-bundle

包简介

A Pimcore bundle that generates Doctrine-like migrations for Documents, Assets, and Data Objects — allowing developers to export Pimcore content structures as executable migration scripts to fully rebuild environments from scratch.

README 文档

README

Compatibility: Pimcore 11 and above.

Pimcore Content Migrations Bundle

The Pimcore Content Migrations Bundle introduces a migration system — similar to Doctrine Migrations — for Documents, Assets, and Data Objects in Pimcore.
It allows developers to export Pimcore content structures as executable PHP migration scripts and rebuild entire environments from scratch, enabling consistent and reproducible deployments across development, staging, and production systems.
The generated migrations create only dummy dependencies — documents, assets, and data objects are included with their content, but without their dependencies or child elements.

📚 Table of Contents

✨ Features

  • Generates migration scripts for Pimcore Documents, Assets, and Data Objects
  • Rebuilds complete content structures on any environment
  • Integrates with version control and deployment workflows

⚙️ Installation

Install the bundle via Composer:

composer require dennispansegrau/pimcore-content-migration-bundle

Add the bundle to your config/bundles.php:

return [
    // ...
    \PimcoreContentMigration\PimcoreContentMigrationBundle::class => ['all' => true],
];

🧰 Configuration

If you do not use doctrine migrations in your project yet, please add following to your config/config.yaml:

doctrine_migrations:
    migrations_paths:
        'App\Migrations\Content': '%kernel.project_dir%/migrations/content'

This defines where generated content migration files are stored.

You can also set a default namespace to avoid passing it every time:

pimcore_content_migration:
    default_namespace: 'App\Migrations\Content'

When set, content:migration:create uses this namespace if none is provided.

🧩 CLI Command

bin/console content:migration:create [TYPE] [ID] [--namespace=...] [--with-children] [--inline-wysiwyg]
Name Description
TYPE The Pimcore element type (document, asset, or object)
ID The ID of the Pimcore element to export
Option Description
--namespace The namespace for the generated migration class (falls back to pimcore_content_migration.default_namespace if set)
--with-children Include all child elements (e.g., sub-documents or child objects) in the migration file
--inline-wysiwyg Inline WYSIWYG field content directly into the migration instead of saving it in a separate HTML file

💻 Example

bin/console content:migration:create document 1 --namespace=App\\Migrations\\Content

This command creates a migration for the document with ID 1 and stores it in the namespace App\Migrations\Content.

🧩 Custom DataType handlers

If you use custom DataTypes (or hit "Unsupported object of class" errors), you can register your own stringifier handler to control how values are serialized in migrations.

Example handler:

<?php

namespace App\ContentMigration\Stringifier;

use App\Model\DataObject\Data\MyCustomDataType;
use PimcoreContentMigration\Converter\Stringifier\ValueStringifier;
use PimcoreContentMigration\Converter\Stringifier\Handler\Trait\ValueToStringConverterTrait;
use PimcoreContentMigration\Generator\Dependency\DependencyList;

final class MyCustomDataTypeStringifier implements ValueStringifier
{
    use ValueToStringConverterTrait;

    public function supports(mixed $value, array $parameters = []): bool
    {
        return $value instanceof MyCustomDataType;
    }

    public function toString(mixed $value, DependencyList $dependencyList, array $parameters = []): string
    {
        $data = $this->getConverter()->convertValueToString($value->getData(), $dependencyList, $parameters);

        return sprintf(
            'new \\App\\Model\\DataObject\\Data\\MyCustomDataType(%s)',
            $data
        );
    }
}

Register it as a service (priority can be adjusted to run before the default handler):

# config/services.yaml
services:
    App\ContentMigration\Stringifier\MyCustomDataTypeStringifier:
        tags:
            - { name: 'pcmb.stringifier_handler', priority: 100 }

🎨 Custom Twig templates

You can override the bundled Twig templates to adapt the generated migration code to your own style. The bundle reads template paths from configuration, so you can point to your own templates.

Example configuration:

# config/config.yaml
pimcore_content_migration:
    templates:
        migration_template: '@App/content_migration/migration.php.twig'
        document_template: '@App/content_migration/document.php.twig'
        asset_template: '@App/content_migration/asset.php.twig'
        object_template: '@App/content_migration/object.php.twig'

When customizing templates, use the Twig helper pcmb_value_to_string to safely serialize Pimcore objects and complex values into PHP code:

{{ pcmb_value_to_string(myValue, dependencies) }}

🧠 Notes

  • Migrations are executable PHP scripts — they can be committed to your VCS and deployed alongside your code.
  • Each migration is idempotent and can safely be executed multiple times.
  • This bundle does not modify Pimcore’s database schema — it only manages content structures.
  • You can organize different types of migrations (Documents, Assets, Objects) under separate namespaces if needed.
  • Please review and test all generated migrations before committing them or running them in production environments.

🧾 License

This bundle is licensed under the MIT License.

dennispansegrau/pimcore-content-migration-bundle 适用场景与选型建议

dennispansegrau/pimcore-content-migration-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 385 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 01 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dennispansegrau/pimcore-content-migration-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dennispansegrau/pimcore-content-migration-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 dennispansegrau/pimcore-content-migration-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 385
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-21