PHP Classes

File: src/TrussServiceProvider.php

Recommend this page to a friend!
  Packages of Alberto Arena   Laravel Truss   src/TrussServiceProvider.php  
File: src/TrussServiceProvider.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Laravel Truss
View a diagram of a Laravel application models
Author: By
Last change: feat: theming and custom palettes (#22)

Let a host redefine the dashboard's colours and fonts from config to
match the app Truss is embedded in. A new truss.theme block exposes a
small set of semantic knobs (accent, background, surface, text, border,
and more) plus two font-family knobs; a ThemeStylesheet service maps each
onto the internal design tokens and emits only the ones set, so a handful
of values re-skins the whole dashboard, chrome and diagram, in both light
and dark, while everything else stays on the shipped default.

The overrides are delivered as a gated, same-origin stylesheet, so a
strict Content-Security-Policy still needs only style-src 'self' and a
default install makes no extra request. Values are validated against a
strict allow-list before they are written into the CSS response, so a
malformed or hostile value is dropped and degrades to the default rather
than breaking or injecting the sheet. Fonts are family names only. The
unused truss.diagram.theme key is removed in favour of truss.theme.
feat: schema export command for CI and tooling (#20)

Add `php artisan truss:export`, the command-line counterpart to the
dashboard export button, so a CI job, script, or tool can pull the
database structure without a human opening the diagram. It writes DBML,
JSON, CSV, a Markdown data dictionary, or Mermaid to stdout by default
or to a file with --output.

The output is deterministic (tables, foreign keys, and indexes are given
a canonical order, and nothing time-, version-, or host-dependent enters
it), so the same schema always produces the same bytes. That makes the
headline CI use case reliable: --check regenerates the export, compares
it against --output, writes nothing, and exits non-zero on drift, failing
a build when a committed schema file has gone stale.

A new src/Export/ layer holds one Generator per format plus a
SchemaExporter service that filters and orders the tables and dispatches
to the generator. The generators are ported from the browser versions in
resources/js; while both coexist they are pinned byte-for-byte to the
same golden fixtures, checked from both Pest and Vitest, so the CLI and
the dashboard download cannot drift. The export reuses the managed-
connection allow-list and the excluded_tables merge, and config
exclusions always win over --tables, so it never widens the structure
surface the dashboard already exposes. Structure only, no row data, no
network call, proven by a canary test that seeds a real row and asserts
it appears in no format.
Date: 6 days ago
Size: 4,296 bytes

You need to be a registered user and login to get this file.

1,618,229 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on: