
A live database structure viewer for Laravel that renders your schema as a scrollable, zoomable ER d
A live database structure viewer for Laravel that renders your schema as a scrollable, zoomable ER d
Laravel Truss is a live database structure viewer. It scans your live schema and renders it as a scrollable, zoomable ER diagram right inside your app, so you can see how the tables actually connect without opening a DB client. It reads structure only (tables, columns, keys, indexes); row data is never queried or exposed.
Try the live demo to pan, zoom, focus, and export a sample schema in your browser, no install needed, then build a palette in the theme builder and copy the config. See what has shipped and what is next on the roadmap.
Stay updated: click Watch > Custom > Releases to hear about new features, follow along in Discussions, or join the Discord.
llm format, from the browser or, for CI and tooling, from the command line with php artisan truss:export. Structure-only and deterministic.--compact, and narrow it with --focus, so the agent stops inventing columns. Structure only, never data.php artisan truss:diff. Structure-only, added / removed / changed tables, columns, indexes, and foreign keys.php artisan truss:doctor, and in a dashboard "Health" panel that flags the same problems on the diagram. Deterministic and structure-only, no AI.Full documentation is at trussphp.com.
For local use, install Truss as a dev dependency:
composer require albertoarena/laravel-truss --devTo run Truss gated on staging or production, install it as a regular dependency instead. Dev dependencies are excluded from composer install --no-dev builds, so a --dev install never reaches a production deploy and /truss returns 404 there:
composer require albertoarena/laravel-trussRequires PHP 8.2+ and Laravel 12+. The service provider is auto-discovered, so there is nothing to publish to get started.
By default Truss is enabled in the local environment only. Start your app and visit:
/trussTo use Truss in a non-local environment you must both enable it and authorize the viewers. See Authorization.
Out of the box Truss visualizes your application's default database connection. If your app spans more than one connection, for example a main database alongside a separate module database, list the connections you want to visualize under truss.connections:
// config/truss.php
'connections' => [
'mysql' => [],
'modules' => ['excluded_tables' => ['module_jobs']],
],When two or more connections are configured, a connection picker appears in the dashboard toolbar. Switching it re-renders that connection's schema, and the selection is kept in the URL so a given view can be shared or bookmarked. Each connection is introspected against its own database only, so a shared server never shows tables that belong to another database.
The keys are Laravel connection names from config/database.php. Per-connection options mirror the global ones (such as excluded_tables), so you can hide different tables on each connection.
Framework and infrastructure tables (migrations, sessions, cache, jobs, and the rest) are hidden by default through excluded_tables. The footer says how much of the connection is on screen, 24 of 32 tables, so a filtered diagram never presents itself as the whole schema, and truss:show reports the same way in the terminal.
A Show hidden tables toggle draws them on request, muted, since they carry no change marks and no health findings. Whether the browser receives them at all is the operator's decision, not the viewer's:
// config/truss.php
'reveal_excluded' => env('TRUSS_REVEAL_EXCLUDED', env('APP_ENV', 'production') === 'local'),On (the default in local, where the dashboard is already open to whoever is looking) they are sent flagged and undrawn, and the toggle appears. Off, they never leave the server and only the count does, so hiding a table to keep it off a shared dashboard keeps working. There is no query parameter for this, by design.
php artisan truss:doctor (aliased truss:check) reviews your database structure for problems visible from structure alone: a table with no primary key, a foreign key with no index, duplicate indexes, money stored as a float, and more. It is deterministic and structure-only, with no AI and no network call, so it is safe to run in CI.
php artisan truss:doctor
php artisan truss:doctor --connection=mysql --format=json
php artisan truss:doctor --preset=strict --fail-on=warningIt exits 0 when clean, 1 when a finding is at or above the --fail-on level (default error), and 2 on a bad option or a snapshot error, so a migration that introduces a problem can fail the build. Presets (recommended, strict, none), per-rule severity and enable / disable, ignore patterns, and the fail level are all configurable under truss.doctor. See the configuration reference.
Every finding carries a stable code (e.g. TRUSS-IDX-001) shown in both the command and the panel; the schema doctor guide lists all the rule codes and what each checks.
Structure only: it reads the same cached snapshot the diagram uses and never queries row data.
The same findings show in the dashboard, under the name Health: the command is truss:doctor, and the dashboard front end for it is the heart icon in the toolbar labelled "Health". Same feature, same findings. The Health panel lists them grouped by table, and every table with a problem carries a small severity badge on the diagram, so you can see what needs attention at a glance. Open the panel to read the findings, click a table to focus it, or click the marked column to see the finding for that field. Heuristic (lower-confidence) findings are marked as such.
It rides the schema endpoint the diagram already loads, so there is no extra request. Two switches control it under truss.doctor:
dashboard (env TRUSS_DOCTOR_DASHBOARD, default on): show the Health panel at all. When off, the dashboard never receives any findings and the CLI is untouched.flag_tables (env TRUSS_DOCTOR_FLAG_TABLES, default on): always badge tables with findings on the diagram, even with the panel closed. Turn it off to keep the diagram clean and surface findings only when the panel is open.php artisan truss:export writes your database structure to a standard format for CI, tooling, and version control. It is the command-line counterpart to the dashboard's export button, generated from PHP so it does not need a human with the diagram open. Deterministic and structure-only, with no network call, so it is safe in CI and commit hooks.
php artisan truss:export # DBML to stdout
php artisan truss:export --format=json # dbml, json, csv, markdown, mermaid, or llm
php artisan truss:export --format=dbml --output=docs/schema.dbml
php artisan truss:export --tables=orders,order_lines # only these (config exclusions still apply)
php artisan truss:export --connection=mysql --exclude=telemetryOutput goes to stdout by default so it pipes cleanly; --output writes a file. The output is deterministic: the same schema always produces the same bytes, whatever order the database reports its tables in. That is what makes the CI drift-check reliable:
# Fail the build if the committed schema file is out of date
php artisan truss:export --format=dbml --output=docs/schema.dbml --check--check regenerates the export, compares it against --output, writes nothing, and exits non-zero when they differ, so a migration that changes the schema without refreshing the committed file fails the build. Exit codes: 0 written or up to date, 1 --check found drift, 2 a usage or runtime error (unknown format, unwritable path, an unmanaged connection, --check without --output, or no tables matched the filters). Add --fresh to rebuild the cached snapshot before exporting.
Config excluded_tables always wins over --tables, so the export never exposes a table the dashboard hides. Structure only: it reads the same cached snapshot the diagram uses and never queries row data.
The same export doubles as grounding context for a coding agent: hand it your real, live structure so it stops inventing columns. Three flags make the output worth pasting or piping into Claude Code, Cursor, or any agent:
php artisan truss:export --format=llm # a dense, token-trimmed plaintext format
php artisan truss:export --compact # drop defaults and non-unique indexes
php artisan truss:export --focus=orders --depth=1 # one table and its FK neighbourhoodAnnotations add the business meaning a type cannot: that status = 1 means paid, that a table is deprecated. Declare them in config/truss.php under annotations (per-table, per-column, and global notes), or read them from native database comments by keeping 'database' in annotations.source. They render into every text format and are stripped with --no-annotations.
This stays structure only. Native comments are part of the CREATE TABLE definition, not row content (the same boundary as column defaults), and no export, in any format or flag combination, ever contains row data. A schema is not a semantic layer: Truss says what exi
No open issues yet, or sync has not completed.