Skip to content

Installation ​

bash
composer require laranex/laravel-schema-viewer:^1.0@alpha --dev

The service provider registers itself. Open /schema-viewer in your local environment; the page loads the built viewer from the package, so there is no npm install and nothing to publish.

Install it as a dev dependency unless your team wants the viewer on a server; see Access.

Access ​

The viewer is on in the local environment and off everywhere else. To open it on a staging or production server, turn it on and say who may see it with the viewSchema gate, for example in AppServiceProvider::boot():

php
use Illuminate\Support\Facades\Gate;

Gate::define('viewSchema', fn ($user) => $user->isAdmin());
ini
SCHEMA_VIEWER_ENABLED=true

Without the gate, the viewer answers 403 outside local. Schema details help an attacker, so keep the gate strict.

Configuration ​

Every setting has a default. Publish the config file only to change one:

bash
php artisan vendor:publish --tag="laravel-schema-viewer-config"
KeyDefaultWhat it does
enabledSCHEMA_VIEWER_ENABLED, unsetUnset: on in local, off elsewhere. true or false decides for every environment.
pathSCHEMA_VIEWER_PATH, schema-viewerThe URL path of the viewer.
domainSCHEMA_VIEWER_DOMAIN, unsetServes the viewer on its own domain.
middleware['web']Route middleware. The viewSchema check is always added.
connectionsnullnull reads the default connection and every connection a model uses. A list reads exactly those, e.g. ['mysql', 'analytics'].
modelsnullFolders scanned for models. null scans app/Models.
exclude_tables[]Tables never shown. Wildcards allowed, e.g. telescope_*.
framework_tablesLaravel's own tables, telescope_*, pulse_*Shown and tagged, so one toggle hides them. They get no hints.
hints.ignore[]Hint kinds, or kind:table pairs, you have accepted.
hints.fail_onforeign_key_without_index, unresolved_relation, model_without_tableKinds that make schema-viewer:check fail.