hiblaphp/schema-manager
Composer 安装命令:
composer require hiblaphp/schema-manager
包简介
Schema, Migration, and Seeding Management for the Hibla Database Ecosystem
README 文档
README
Asynchronous migrations, seeders, and programmatic schema definition for PHP 8.4+.
Note: This repository provides the CLI tooling and schema builder for the Hibla Database Ecosystem. For complete, comprehensive documentation covering all CLI commands, Blueprint definitions, and Query Builder features, please visit the main hiblaphp/database meta-package.
Overview
hiblaphp/schema-manager is a standalone database lifecycle management toolkit. It equips any PHP application or microframework with Laravel-style migrations, programmatic blueprints, asynchronous database seeders, and advanced production safeguards like "Safe Mode" and native Schema Dumping (Squashing).
It supports MySQL, PostgreSQL, and SQLite out of the box. Notably, it fully overcomes SQLite's infamous ALTER TABLE limitations by safely orchestrating atomic table-recreation and index-preservation within asynchronous transactions automatically.
Installation
This package is currently in beta. Before installing, ensure your
composer.jsonallows beta releases:
Install the package via Composer. (This automatically installs the required hiblaphp/query-builder dependency).
composer require hiblaphp/schema-manager
Run the initialization command to auto-scaffold your configuration files:
# Places configs in a /config directory for instant auto-discovery
./vendor/bin/hibla-db init --dir=config
Quick Start
Zero-Config Default: By default, Hibla resolves to an in-memory SQLite database (
:memory:), meaning you can start running migrations and seeders immediately without configuring a database server!
1. Create a Migration
Generate your first migration using the CLI. The command automatically detects table creation intents based on the name:
./vendor/bin/hibla-db make:migration create_users_table
This generates a safe, anonymous class in your database/migrations folder:
<?php use Hibla\SchemaManager\Schema\Blueprint; use Hibla\SchemaManager\Schema\Migration; use function Hibla\await; return new class extends Migration { public function up(): void { await($this->create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->timestamps(); })); } public function down(): void { await($this->dropIfExists('users')); } };
2. Run the Migrations
Apply your schema to the database safely:
./vendor/bin/hibla-db migrate
3. Create a Seeder
Generate a database seeder file:
./vendor/bin/hibla-db make:seeder UserSeeder
Seed your data using highly optimized, asynchronous queries:
<?php use Hibla\SchemaManager\Schema\Seeder; use function Hibla\await; return new class extends Seeder { public function run(): void { await($this->db('users')->insertBatch([ ['name' => 'Alice', 'email' => 'alice@test.com'], ['name' => 'Bob', 'email' => 'bob@test.com'], ])); } };
Run your seeders:
./vendor/bin/hibla-db db:seed
Testing & Development
Because the Schema Manager tests native table alterations, foreign key bindings, and schema state dumping, the test suite requires real databases to run against. A docker-compose.yml file is provided to quickly spin up the necessary environments for MySQL and PostgreSQL.
1. SQLite Testing (Zero Setup)
To run the SQLite test suite, no external database engines or Docker setups are required. Simply execute:
composer test:sqlite
2. Start the External Database Containers
Start the MySQL 8 and PostgreSQL 15 containers:
docker compose up -d
3. Run the Suite
To run the tests against MySQL:
composer test:mysql
To run the tests against PostgreSQL:
composer test:pgsql
To run the tests against all three databases sequentially:
composer test:all
Documentation
For full documentation on available Blueprint column types, multi-connection migrations, production Safe Mode, and Schema Squashing (schema:dump), please read the Comprehensive Hibla Documentation.
License
This package is open-sourced software licensed under the MIT license.
hiblaphp/schema-manager 适用场景与选型建议
hiblaphp/schema-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hiblaphp/schema-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hiblaphp/schema-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 44
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-08