Laravel Module Generator

v 1.3.*

DBML to YAML

dbdiagram:import — Import DBML and generate YAML

Generate a YAML schema file from an existing DBML (Database Markup Language) file. This is useful when you've designed your database schema in dbdiagram.io and want to generate the YAML configuration.

Signature:

php artisan dbdiagram:import
    {--file= : Path to the DBML file}
    {--output= : Path to the output YAML file}

Options:

  • --file=path/to/file.dbml — Input DBML file (default: module/dbdiagram.dbml)
  • --output=path/to/output.yaml — Output YAML file (default: module/models.yaml)

Examples:

# Import with defaults
php artisan dbdiagram:import

# Import from custom DBML file
php artisan dbdiagram:import --file=schemas/database.dbml

# Import and save to custom location
php artisan dbdiagram:import \
  --file=exports/schema.dbml \
  --output=module/models-new.yaml

Features:

  • Automatically converts DBML table definitions to YAML format
  • Detects and maps relationships (belongsTo, hasMany)
  • Handles foreign keys and converts them to foreignId fields
  • Preserves unique constraints, nullable fields, and default values
  • Generates compact relation format
  • Prompts before overwriting existing YAML files

Workflow:

  1. Design your database schema at dbdiagram.io
  2. Export/copy the DBML code
  3. Save it to a .dbml file
  4. Run php artisan dbdiagram:import
  5. Review the generated YAML file
  6. Run php artisan module:generate to create your modules