Laravel Schema Docs

Laravel Schema Docs

Latest Stable Version Total Downloads License
View Package

laravel schema docs

Overview: Laravel Schema Docs

Managing and understanding database schemas can be challenging, especially as Laravel projects grow in complexity. Laravel Schema Docs is a powerful package designed to make this process simple and efficient. With this tool, developers can generate comprehensive YAML documentation of their Laravel database schema and explore it through an intuitive dashboard, all without leaving their application.

Key Features

  • YAML Documentation: Export your database schema in a structured YAML format for easy reference, sharing, or integration with other tools.
  • Visual Dashboard: Explore your tables, columns, and relationships directly in a clean, interactive dashboard.
  • Laravel-Friendly: Seamlessly integrates into any Laravel project with minimal setup.
  • Developer Productivity: Helps developers quickly understand the database structure, reducing onboarding time and improving maintenance.

Whether you’re working on a solo project or collaborating with a team, Laravel Schema Docs provides a clear, organized, and developer-friendly way to document and visualize your database schema.

Installation: Begin by installing the package via Composer:

composer require dipesh79/laravel-schema-docs

Next, publish the vendor file to customize settings:

php artisan vendor:publish --provider="Dipesh79\LaravelSchemaDocs\Providers\LaravelSchemaDocsServiceProvider"

Usage: Generate yaml file.

php artisan laravelschemadocs:generate

Now you are good to go.

http://localhost:8000/laravel-schema-docs

Additionally you can update the yaml file which will be generated at root of the laravel project to add logic of the column. For e.g.

tables:
    blog_comments:
        columns:
            id: { type: bigint, nullable: false, default: null, primary: true, unique: false, comment: '', logic: '' }
            created_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            updated_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
        relations: {  }
    blogs:
        columns:
            id: { type: bigint, nullable: false, default: null, primary: true, unique: false, comment: '', logic: '' }
            user_id: { type: bigint, nullable: false, default: null, primary: false, unique: false, comment: '', logic: '' }
            status: { type: varchar, nullable: false, default: draft, primary: false, unique: false, comment: 'draft, published, archived', logic: 'Show Published Only to Frontend' }
            created_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            updated_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
        relations:
            - { column: user_id, references: users, 'on': id }
    categories:
        columns:
            id: { type: bigint, nullable: false, default: null, primary: true, unique: false, comment: '', logic: '' }
            name: { type: varchar, nullable: false, default: null, primary: false, unique: false, comment: '', logic: '' }
            created_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            updated_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
        relations: {  }
    users:
        columns:
            id: { type: bigint, nullable: false, default: null, primary: true, unique: false, comment: '', logic: '' }
            name: { type: varchar, nullable: false, default: null, primary: false, unique: false, comment: '', logic: '' }
            email: { type: varchar, nullable: false, default: null, primary: false, unique: true, comment: '', logic: '' }
            email_verified_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            password: { type: varchar, nullable: false, default: null, primary: false, unique: false, comment: '', logic: '' }
            remember_token: { type: varchar, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            created_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
            updated_at: { type: timestamp, nullable: true, default: null, primary: false, unique: false, comment: '', logic: '' }
        relations: {  }

Example with Context

status:
  type: varchar
  nullable: false
  default: draft
  primary: false
  unique: false
  comment: 'draft, published, archived'
  logic: 'Show Published Only to Frontend'
  • Here, status is a required varchar column with a default value of draft.
  • The comment shows all possible values which was added in migration.
  • The logic gives developers guidance on how this field should be used in the application.

Disable Url

Just put this on your .env file

SHOW_SCHEMA_DOCS=false

Summary

By defining your columns this way, Laravel Schema Docs allows:

  • Clear, structured documentation of your database schema.
  • Easy integration with YAML exports.
  • Adding custom developer notes using the logic field for team collaboration or future reference.

This approach keeps your schema both machine-readable and developer-friendly.


License: MIT

Support: For support, email dipeshkhanal79@gmail.com.

This post is licensed under CC BY 4.0 by the author.