承接 sylvainduval/dynamic-db-bundle 相关项目开发

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

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

sylvainduval/dynamic-db-bundle

Composer 安装命令:

composer require sylvainduval/dynamic-db-bundle

包简介

Build and edit your database schema with PHP.

README 文档

README

Object-Oriented Database Schema Management for PHP

Description

DynamicDB is a lightweight and expressive PHP bundle that enables you to manage database schemas dynamically through an object-oriented API.

Unlike traditional ORMs or migration systems that rely on static entity definitions and diffs, DynamicDB gives you full control over your schema operations — explicitly and programmatically.

This makes it ideal for applications where the database structure must adapt to dynamic or user-defined data models, such as:

  • Product Information Management (PIM) systems
  • Digital Asset Management (DAM) tools
  • Reporting or analytics platforms
  • Data mining or ETL tools
  • Any schema-on-the-fly use case

With DynamicDB, you can:

  • Create and drop databases or tables programmatically
  • Define fields using PHP objects and set their attributes
  • Add, modify or delete fields explicitly
  • Run schema operations in install scripts, migrations, or runtime processes

Key Principles & Advantages

Clear Responsibilities

  • You decide what should happen: create, modify, or delete.
  • No hidden diffs or magic. DynamicDB executes exactly what you tell it.

Fluent and Readable API

  • Object-oriented syntax makes your schema definition self-documented.
  • Easy to version, organize, and replay (e.g. in migrations or CLI scripts).

Method-Based Flexibility

Core operations are exposed via stable and testable methods:

  • createDatabase()
  • deleteDatabase()
  • createTable()
  • createFields()
  • changeField()
  • deleteField()
  • ...

Each schema component is represented as an object (Database, Table, Field), making it easy to encapsulate logic and manipulate structure dynamically. Database-specific settings for MySQL and PostgreSQL can be provided via dedicated options domain objects.

Lazy loading

No connection is opened, and no SQL is executed, until the first operation is explicitly called. This allows for deferred execution and better control over when and how the database is accessed.

Getting Started

Dependencies

  • PHP >= 8.4
  • PDO or mysqli driver
  • MySQL >= 5.7, MariaDB >= 10.7 or PostgreSQL

Also suggested requirements for dependency injection :

  • psr/container: Required if you use standalone bridge
  • symfony/dependency-injection: Required if you use Symfony

Development Setup with Docker

For development, this project includes a complete Docker environment with PHP 8.4, MySQL, MariaDB, and PostgreSQL.

Prerequisites

  • Docker and Docker Compose v2 installed on your system

Quick Start

  1. Clone the repository and navigate to the project directory

  2. Start the Docker environment:

make up
  1. Install dependencies:
make install
  1. Run tests to verify everything works:
make test

Available Make Commands

  • make help - Show all available commands
  • make up - Start all Docker services
  • make down - Stop all Docker services
  • make shell - Open a shell in the PHP container
  • make install - Install Composer dependencies
  • make test - Run all PHPUnit tests
  • make test-unit - Run only unit tests
  • make test-integration - Run only integration tests
  • make phpstan - Run PHPStan static analysis
  • make cs-fix - Fix code style with PHP-CS-Fixer
  • make cs-check - Check code style without fixing
  • make clean - Clean up containers, volumes, and caches

Manual Docker Commands

If you prefer not to use the Makefile:

# Start services
docker compose up -d

# Run tests
docker compose exec php vendor/bin/phpunit

# Run PHPStan
docker compose exec php vendor/bin/phpstan analyse

# Fix code style
docker compose exec php vendor/bin/php-cs-fixer fix

Installing

  1. Reference it in your composer.json:
composer require sylvainduval/dynamic-db-bundle
  1. With Symfony

This bundle does not have a Symfony Flex recipe yet. You must add this line in config/bundles.php:

<?php 

return [
	...
	SylvainDuval\DynamicDbBundle\Bridge\Symfony\DynamicDbSymfonyBundle::class => ['all' => true],
];

And set up your database connection in config/packages/dynamic_db.yaml:

dynamic_db:
    host: 'db'
    port: 3306
    user: '***'
    password: '***'
    database: null
    charset: 'utf8mb4'
  1. Without Symfony

Register the service in your own PSR container :

<?php

require __DIR__ . '/../vendor/autoload.php';

$container = new App\Container();

$bundle = new \SylvainDuval\DynamicDbBundle\Bridge\Standalone\DynamicDbRegistrar();
$bundle->register([
    'host' => 'db',
    'port' => 3306,
    'user' => '***',
    'password' => '***',
    'database' => null,
    'charset' => 'utf8mb4'
], $container);

Todo

Global:

  • Improve exceptions and add query context in it

MySQL / MariaDB:

  • Foreign keys contraints
  • autoincrement UNIQUE, not only PRIMARY KEY
  • Others database and table options
  • ENUM field type
  • DATE and DATETIME field: support option with timezone
  • Add field: after / before
  • ...

PostgreSQL:

  • Schema management
  • Foreign keys contraints
  • Others database and table options
  • ENUM field type
  • JSON field: supports option binary version (JSONB)
  • GEOMETRY and POINT fields: supports option for default value and SRID identifier
  • DATE and DATETIME field: support option with timezone (TIMESTAMPTZ)
  • Add field: after / before
  • Change field: supports null / not null changes
  • ...

Authors

Contributors names and contact info

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgments

This project was inspired by several tools and concepts around schema versioning and database management:

  • Liquibase – A powerful database schema change management tool that inspired the idea of declarative and trackable schema changes.
  • Doctrine Migrations – For its structured approach to PHP-based migrations.
  • Laravel Migrations – For its clean, fluent API to define schema changes in code.
  • Flyway – For its emphasis on versioned migrations and repeatability.

Special thanks to the open-source community for the many ideas and design patterns that influenced this bundle.

sylvainduval/dynamic-db-bundle 适用场景与选型建议

sylvainduval/dynamic-db-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 sylvainduval/dynamic-db-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-06