DBML to Laravel CLI

Artisan commands for Laravel that build Eloquent models and migrations from a DBML schema and carry schema edits into new ones

  • 75 ★ on the repository
  • Last commit
  • MIT
CLI

Extended access

Why this level

  • `dbml:generate` and `dbml:sync` create and edit model and migration files in the project
  • Migrations generated from the schema change the database structure when `php artisan migrate` runs
All reasons and checks

egyjs/dbml-to-laravel

Install

Manual install

composer require egyjs/dbml-to-laravel --dev

Then `php artisan dbml:generate database/schema.dbml`. The Laravel Boost skill is wired by `php artisan boost:install`.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • `dbml:generate` and `dbml:sync` create and edit model and migration files in the project
  • Migrations generated from the schema change the database structure when `php artisan migrate` runs

This is third-party code. Review the repository files before installing.

What it does

DBML to Laravel is a Composer package that reads a DBML schema, including one from dbdiagram.io, and creates the Laravel data layer. `php artisan dbml:generate database/schema.dbml` writes models with `$fillable`, `$casts` and `belongsTo` and `hasMany` relations, plus migrations with column types, defaults, unique keys, indexes, foreign keys and enums. On the first run the package saves a schema snapshot. After you edit the schema, `php artisan dbml:sync database/schema.dbml --force` compares the file with the snapshot, creates migrations for additions, changes and drops, and patches models only inside `@dbml-sync` markers. The rest of the model code stays yours. There is a dedicated agent mode: `--force` removes prompts, `--dry-run` lists files without writing, `--json` prints a report with `success`, `written`, `skipped` and `errors`, and exit code 1 reports an error. The package ships Laravel Boost guidelines and a skill in `resources/boost/`, wired by `php artisan boost:install`.

Who it is for. Laravel developers who keep the database schema in one DBML file and want to hand schema edits to an agent without hand-written migrations.

Good fit when

  • The schema is drawn in dbdiagram.io and you need models and migrations for a new app
  • An agent must change the database by editing one `database/schema.dbml` file and running `dbml:sync`
  • You want a preview: which files would be written, with no changes on disk
  • After a schema edit you need incremental migrations with no table re-creation

Not a fit when

  • You need to rebuild DBML from an existing database: the package works only from DBML to code
  • You need controllers, factories or seeders: the package does not create them
  • The schema has many one-to-one and many-to-many relations: the package skips them

Example request

Add a comments table referencing posts to the DBML schema, show a dry run first, then apply dbml:sync and return the JSON report

Limitations

Only many-to-one and one-to-many relations (the `>` and `<` signs) are used, while one-to-one and many-to-many are ignored: no foreign keys, `hasOne`, pivot tables or `belongsToMany` come from them. `$hidden`, factories and seeders are not generated, and columns without `not null` get `->nullable()`. Without `--force`, `dbml:sync` in a shell with no terminal exits with code 1. Incremental migrations rely on the schema snapshot, so do not delete it between runs.

How to disable. Remove the package with `composer remove egyjs/dbml-to-laravel --dev`. Models and migrations already created stay in the project, and the `@dbml-sync` markers in models can be erased by hand.

FAQ

How do I run the first generation?

Put the schema in `database/schema.dbml` and run `php artisan dbml:generate database/schema.dbml`. The command creates models, migrations and a schema snapshot for later syncing.

How is dbml:sync different from dbml:generate?

`dbml:generate` creates code from a schema from scratch, while `dbml:sync` compares the schema with the snapshot and emits only migrations for the changes, patching models inside `@dbml-sync` markers.

What does the --json flag print?

One JSON report: `success`, `dry_run`, a `written` list, a `skipped` list with reasons and `errors` messages. Exit code 0 means success and 1 any error.

How do I wire the agent skill?

The package ships Laravel Boost guidelines and a skill in `resources/boost/`. Wire them with `php artisan boost:install` or `boost:update`.

Can I change the code templates?

Yes, `php artisan vendor:publish --tag=dbml-to-laravel-stubs` copies model and migration stubs into the project for editing to your style.

Discussion

No questions or reviews yet.

CLI tools
Official

Laravel's official MCP server, guidelines and skills: the agent sees the DB schema, logs and package versions and searches ecosystem docs

MCP serverExtended access3.7KRepository stars
Needs a VPN

Anthropic Laravel puts the Claude API behind a Laravel facade and ships a Laravel Boost skill so agents write code for the package

SkillExtended access74Repository stars

Laravel API Architecture Skill

Laravel API Production-Ready Architecture Skill

A skill that keeps an agent within a layered Laravel API architecture: JSON:API v1.1, strict types, PHPStan level 8 and tests

SkillMinimal access22Repository stars

A Laravel and Lumen package that adds an MCP endpoint to your app's routes and attaches your own tools to it

MCP serverExtended access331Repository stars

Skills for Laravel Boost and the Neuron AI package: an agent writes PHP AI agents, chat memory, evaluation and frontend glue

SkillExtended access123Repository stars
Official

Four skills with Spatie's standards for Laravel, PHP, JavaScript, git and security, installed via Laravel Boost or skills.sh

SkillMinimal access100Repository stars

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialAuthenticationRepository starsMain difference
DBML to Laravel (this card)no75
Laravel Boostyesnot required3,690the official Laravel MCP server and skills with no code generation from a schema
Laravel Agent Skillsyes737the official collection of Laravel skills

README in short

The README opens with a three-command quick start, then explains when the package fits and lists features and limitations. Installation, a DBML schema example, generation, syncing and a section on working with AI agents follow.

README badge

Report a problem