PHPackages                             eril/schema-engine - 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. eril/schema-engine

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

eril/schema-engine
==================

Schema-first database migration engine for PHP.

v0.3.0(1w ago)02↓100%MITPHPPHP ^8.2CI passing

Since May 24Pushed 1w agoCompare

[ Source](https://github.com/erilshackle/php-schema-engine)[ Packagist](https://packagist.org/packages/eril/schema-engine)[ RSS](/packages/eril-schema-engine/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

PHP Schema Engine
=================

[](#php-schema-engine)

A modern schema-first migration engine for PHP.

PHP Schema Engine lets you define your database structure using a clean PHP DSL, compare it against the current database schema, generate SQL automatically, and apply changes through a lightweight CLI.

> Current version: `0.3.0`

[![PHP](https://camo.githubusercontent.com/187240af044d09d5b14a1d9d9ebdf3f7a993e4c7bc09bdb46b4ba661a891bf5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c7565)](https://camo.githubusercontent.com/187240af044d09d5b14a1d9d9ebdf3f7a993e4c7bc09bdb46b4ba661a891bf5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c7565)[![Tests](https://github.com/erilshackle/php-schema-engine/actions/workflows/tests.yml/badge.svg)](https://github.com/erilshackle/php-schema-engine/actions/workflows/tests.yml/badge.svg)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)

---

Features
--------

[](#features)

- Schema-first database definition
- Fluent PHP DSL
- MySQL/MariaDB support
- Automatic schema introspection
- Table and column diffing
- Partial index diffing
- SQL generation
- Migration execution
- Migration history
- Model generation
- Dry-run mode
- Destructive operation protection
- Database reset support
- Snapshot generation
- Foreign key support
- Debug trace mode

---

Installation
------------

[](#installation)

```
composer require eril/schema-engine
```

---

Initialization
--------------

[](#initialization)

Generate the default configuration file:

```
php bin/migrate --init
```

This creates:

```
schema-engine.php
database/schema.php
database/bootstrap.sql
database/snapshots/
```

---

Configuration
-------------

[](#configuration)

Generated config example:

```
