PHPackages                             leafs/schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. leafs/schema

ActiveLibrary[Database &amp; ORM](/categories/database)

leafs/schema
============

Git for your database

v0.1.1(6mo ago)01.0k—0%2[2 PRs](https://github.com/leafsphp/schema/pulls)1MITPHP

Since Oct 20Pushed 6mo agoCompare

[ Source](https://github.com/leafsphp/schema)[ Packagist](https://packagist.org/packages/leafs/schema)[ Docs](https://leafphp.dev/docs/database/files.html)[ GitHub Sponsors](https://github.com/leafsphp)[ Fund](https://opencollective.com/leaf)[ RSS](/packages/leafs-schema/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (1)

 [![](https://camo.githubusercontent.com/d98ee5e32c2ff016fdfdac6c42654a908f4cc34b229c7b00caacc5a717455ae8/68747470733a2f2f6c6561667068702e6465762f6c6f676f2d636972636c652e706e67)](https://camo.githubusercontent.com/d98ee5e32c2ff016fdfdac6c42654a908f4cc34b229c7b00caacc5a717455ae8/68747470733a2f2f6c6561667068702e6465762f6c6f676f2d636972636c652e706e67)

Leaf Schema
===========

[](#leaf-schema)

[![Latest Stable Version](https://camo.githubusercontent.com/dcaf208122c1fdc9c5a162a32b40ece69b0a2a211f738a348487df1772786fed/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f736368656d612f762f737461626c65)](https://packagist.org/packages/leafs/schema)[![Total Downloads](https://camo.githubusercontent.com/6d3648c653f23e70395692acaac957b35363164c0f2fb869596f087bf00c25bb/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f736368656d612f646f776e6c6f616473)](https://packagist.org/packages/leafs/schema)[![License](https://camo.githubusercontent.com/fba4501fe922d394053b0598cfd66c71995401c85b9b8d8b09942844b70e983d/68747470733a2f2f706f7365722e707567782e6f72672f6c656166732f736368656d612f6c6963656e7365)](https://packagist.org/packages/leafs/schema)

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
```

Schema Files
------------

[](#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](https://leafphp.dev/docs/database/files.html#schema-columns).

Migrating Schema Files
----------------------

[](#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

[](#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

[](#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](https://leafphp.dev/docs/database/files.html) for the full documentation on schema files and all the available commands.

💬 Stay In Touch
---------------

[](#-stay-in-touch)

- [Twitter](https://twitter.com/leafphp)
- [Join the forum](https://github.com/leafsphp/leaf/discussions/37)
- [Chat on discord](https://discord.com/invite/Pkrm9NJPE3)

📓 Learning Leaf 3
-----------------

[](#-learning-leaf-3)

- Leaf has a very easy to understand [documentation](https://leafphp.dev) which contains information on all operations in Leaf.
- You can also check out our [youtube channel](https://www.youtube.com/channel/UCllE-GsYy10RkxBUK0HIffw) 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
--------------

[](#-contributing)

We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our [contribution guide](https://leafphp.dev/community/contributing.html) and you'll be ready to make your first pull request 🚀.

To report a security vulnerability, you can reach out to [@mychidarko](https://twitter.com/mychidarko) or [@leafphp](https://twitter.com/leafphp) on twitter. We will coordinate the fix and eventually commit the solution in this project.

🤩 Sponsoring Leaf
-----------------

[](#-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](https://opencollective.com/leaf) or check the [contribution page](https://leafphp.dev/support/) for a list of ways to contribute.

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

### Cash contributors

[](#cash-contributors)

   [ ![](https://camo.githubusercontent.com/43586d8f5e07014bc26b4f937b4b231520f65723d7cd23c92af58411ae6e8295/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f6161726f6e2d736d697468332f303865653632302f6176617461722f3235362e706e67)
 **Aaron Smith** ](https://opencollective.com/aaron-smith3)   [ ![](https://camo.githubusercontent.com/e98947a206f1d93c9ca8711e566e5c10d529f32ac6063aeecac96cd17ebdb3b5/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f70657465722d626f676e65722f6176617461722f3235362e706e67)
 **Peter Bogner** ](https://opencollective.com/peter-bogner)   [ ![](https://camo.githubusercontent.com/e6a7c11e7c47883f1ec06ab44f4b3cb96046f8fc3d939919bc889a44f7d1e4cd/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f67756573742d33323633346664612f6176617461722e706e67)
 **Vano** ](#)  🤯 Links/Projects
----------------

[](#-linksprojects)

- [Aloe CLI](https://leafphp.dev/aloe-cli/)
- [Leaf Docs](https://leafphp.dev)
- [Leaf MVC](https://mvc.leafphp.dev)
- [Leaf API](https://api.leafphp.dev)
- [Leaf CLI](https://cli.leafphp.dev)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance66

Regular maintenance activity

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

208d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29547806?v=4)[Mychi](/maintainers/Mychi)[@mychi](https://github.com/mychi)

---

Top Contributors

[![mychidarko](https://avatars.githubusercontent.com/u/26604242?v=4)](https://github.com/mychidarko "mychidarko (6 commits)")

---

Tags

phpschemadatabasemigrationsleaf

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/leafs-schema/health.svg)

```
[![Health](https://phpackages.com/badges/leafs-schema/health.svg)](https://phpackages.com/packages/leafs-schema)
```

###  Alternatives

[nwidart/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

37839.1k](/packages/nwidart-db-exporter)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)[leafs/cli

A simple command line tool for installing and interacting with your leaf apps

149.0k](/packages/leafs-cli)[elimuswift/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

364.7k](/packages/elimuswift-db-exporter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
