leafs/schema 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

leafs/schema

Composer 安装命令:

composer require leafs/schema

包简介

Git for your database

README 文档

README



Leaf Schema

Latest Stable Version Total Downloads License

Schema files are a new way to define and manage your database structure in Leaf applications. Instead of writing complex migration files using PHP, and then managing multiple migrations for a single database table, you can now define a simplified structure using yml and let Leaf handle the rest.

This module packages the schema functionality into a standalone package which can be used in any PHP application once the port is complete.

If you use Leaf MVC, this is already included and configured for you.

To get started, install the schema module:

leaf install schema
# or
composer require leafs/schema

Once installed, you can start creating your schema files using the g:schema command:

./vendor/bin/leaf g:schema <name>

Schema Files

Schema Files allow you to define your database tables, seed data, and keep track of your database automatically in one simple YAML file. They are clean, readable, and designed to help you move fast without the overhead. Every schema file is tied to a table in your database, for example, if you create a schema file called flights, it will be tied to the flights table in your database.

We can do this by running the command below:

./vendor/bin/leaf g:schema flights

This will create a new file in the database directory called flights.yml. You can open this file and start defining your table structure.

columns:
  to: string
  from: string
  identifier: string

seeds:
  count: 10

In this example, we have defined a table with three columns: to, from, and identifier, which are all of type string in this case, but can be any valid column type. You can view a full list of column types in the documentation.

Migrating Schema Files

Once you have defined your schema file, you can create the table in your database by running the migrate command:

./vendor/bin/leaf db:migrate

This command will read all the schema files in the database directory and create the corresponding tables in your database. If the table already exists, it will update the table structure to match the schema file. You can also migrate a specific schema file by passing the name of the file as an argument:

./vendor/bin/leaf db:migrate flights

Syncing Changes

The major difference between schema files and traditional migrations is that you don't have to create a new migration file every time you want to make a change to your table structure. Instead, you can simply update the schema file and run the migrate command again. Leaf will automatically detect the changes and apply them to the database if it is aware of the previous state of the table.

Other commands

You can perform other operations on your schema files like rolling back changes, refreshing the database, and seeding data. We recommend checking out the documentation for the full documentation on schema files and all the available commands.

💬 Stay In Touch

📓 Learning Leaf 3

  • Leaf has a very easy to understand documentation which contains information on all operations in Leaf.
  • You can also check out our youtube channel which has video tutorials on different topics
  • We are also working on codelabs which will bring hands-on tutorials you can follow and contribute to.

😇 Contributing

We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request 🚀.

To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.

🤩 Sponsoring Leaf

Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.

And to all our existing cash/code contributors, we love you all ❤️

Cash contributors


Aaron Smith

Peter Bogner

Vano

🤯 Links/Projects

leafs/schema 适用场景与选型建议

leafs/schema 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.53k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「migrations」 「php」 「schema」 「leaf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 leafs/schema 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-24