How rajeshmk/laravel-db-explorer works
1. What this repo is
- This is a Laravel package, not a standalone app.
- Its purpose is to mount a database schema/data explorer into a host Laravel application at a route like /db-explorer.
2. Package bootstrap
- src/DbExplorerServiceProvider.php is the integration hub.
- It likely registers the package’s routes, config, views, migrations, commands, and frontend assets into the host app.
- The package is controlled by config/db-explorer.php.
3. Access control boundary
- src/Http/Middleware/EnsureDbExplorerIsAllowed.php is the main security gate.
- The README indicates it blocks access unless:
- the explorer is enabled, and
- the current environment is in the allowed list.
- The route middleware stack is configurable, defaulting to web and auth.
4. HTTP/API layer
- routes/web.php defines the public package routes.
- src/Http/Controllers/ExplorerController.php is the main request handler.
- The controller likely serves:
- the dashboard/table list,
- schema/table detail pages,
- table browsing/search,
- and optionally write actions when write mode is enabled.
5. Database inspection layer
- src/Inspectors/MySqlInspector.php is the core metadata/data access component.
- It is responsible for reading tables, columns, indexes, foreign keys, and rows from the database.
- The name strongly suggests the package is currently MySQL-focused rather than database-agnostic.
6. Presentation metadata layer
- src/Models/ColumnPresentation.php plus the migration in database/migrations/...create_db_explorer_column_presentations_table.php provide persistence for per-column UI presentation settings.
- This is how the package can remember things like text, textarea, number, date/time, boolean, dropdown, foreign-key dropdown, or color picker presentation choices.
7. Type-resolution helpers
- src/Support/PresentationTypeResolver.php converts column metadata into a UI control type.
- src/Support/EnumValueExtractor.php suggests the package also derives selectable values from PHP enums or enum-like column definitions.
- Together these helpers sit between schema inspection and frontend form rendering.
8. Frontend application
- resources/js/app.js boots a Vue app defined in resources/js/App.vue.
- The main screens are resources/js/views/Dashboard.vue and resources/js/views/Explorer.vue.
- These views provide the interactive explorer experience: table browsing, metadata display, record grids, and editing controls.
9. Blade shell and server-rendered wrappers
- resources/views/layout.blade.php is the main host layout.
- resources/views/schema.blade.php, table.blade.php, tables.blade.php, and pagination.blade.php are server-rendered templates that wrap or complement the Vue-driven UI.
- This suggests a hybrid architecture: Laravel renders the shell and page structure, while Vue powers richer in-page interactions.
10. Compiled assets and build pipeline
- The distributable frontend lives in resources/dist/db-explorer.css and resources/dist/db-explorer.iife.js.
- vite.config.js and package.json indicate the package is built with Vite and ships precompiled browser assets for installation into a host app.
- The installer command and publish tags exist largely to copy these assets into the consuming project.
11. Installation/update workflow
- src/Console/Commands/InstallCommand.php and UpdateCommand.php automate publishing assets/config/views/migrations.
- This package is designed to be installed via Artisan commands as well as through normal Laravel vendor publishing.
- If write mode is enabled, database migrations become part of the runtime requirements.
12. Runtime data flow
- Browser request hits the Laravel route.
- Middleware checks whether the explorer is allowed.
- Controller delegates to the MySQL inspector and presentation helpers.
- Results are passed to Blade/Vue to render schemas, tables, rows, and forms.
- If write mode is enabled, user actions feed back through the controller into the database.
13. Architectural boundary to note
- There is a clean split between:
- package infrastructure (service provider, commands, config, middleware),
- schema/data access (MySQL inspector, column presentation model),
- UI/rendering (Vue + Blade + compiled assets).
- That separation is what you would want to show on an architecture diagram.
14. Operational posture
- The README emphasizes that the explorer is disabled by default, restricted by environment, and optional write support is off unless explicitly enabled.
- This is a deliberately security-sensitive admin tool layered into an existing Laravel app rather than a general-purpose public UI.
Main entry points: ExplorerController.php Explorer controller · DbExplorerServiceProvider.php Service provider · vite.config.js Vite build · Explorer.vue Explorer
Components 25
Package infra
Laravel package bootstrap, config, and install/update workflow.
- Service provider · Registers the package into the host Laravel app.
src/DbExplorerServiceProvider.php - Config · Feature flags, route/middleware settings, and explorer behavior.
config/db-explorer.php - Install cmd · Publishes package resources for first-time setup.
src/Console/Commands/InstallCommand.php - Update cmd · Republishes or refreshes package assets and resources.
src/Console/Commands/UpdateCommand.php
HTTP access
Route entrypoints, middleware, and controller boundary.
- Web routes · Public package routes mounted into the host app.
routes/web.php - Allow gate · Blocks the explorer unless it is enabled and the environment is allowed.
src/Http/Middleware/EnsureDbExplorerIsAllowed.php - Explorer controller · Handles dashboard, schema, table browsing, and write actions.
src/Http/Controllers/ExplorerController.php
Data inspection
Database metadata and persisted presentation settings.
- MySQL inspector · Reads tables, columns, indexes, foreign keys, and rows from MySQL.
src/Inspectors/MySqlInspector.php - Column presentation · Stores per-column UI presentation preferences.
src/Models/ColumnPresentation.php - Presentation migration · Creates the storage table for column presentation settings.
database/migrations/2026_02_12_000001_create_db_explorer_column_presentations_table.php - Type resolver · Maps schema metadata to a form control type.
src/Support/PresentationTypeResolver.php - Enum extractor · Derives selectable values from PHP enums or enum-like definitions.
src/Support/EnumValueExtractor.php
UI layer
Blade wrappers, Vue app, and compiled frontend assets.
- Layout shell · Main server-rendered wrapper for the explorer.
resources/views/layout.blade.php - Tables view · Server-rendered table and schema wrappers.
resources/views/tables.blade.php - Schema view · Server-rendered schema page wrapper.
resources/views/schema.blade.php - Table view · Server-rendered table detail wrapper.
resources/views/table.blade.php - Pagination · Pagination fragment used by the server-rendered tables.
resources/views/pagination.blade.php - Vue app · Boots the interactive explorer application.
resources/js/app.js - App shell · Top-level Vue component for the explorer UI.
resources/js/App.vue - Dashboard · Overview screen for databases, schemas, or tables.
resources/js/views/Dashboard.vue - Explorer · Interactive table browsing and editing screen.
resources/js/views/Explorer.vue - Explorer CSS · Distributed stylesheet for the packaged UI.
resources/dist/db-explorer.css - Explorer bundle · Distributed browser bundle for the packaged UI.
resources/dist/db-explorer.iife.js
Build pipeline
Frontend build and package metadata.
- Vite build · Build configuration for the distributable frontend assets.
vite.config.js - Package manifest · Frontend package metadata and scripts.
package.json
Connections 35
- Service provider → Config: loads · Service provider consumes package configuration.
- Service provider → Web routes: registers · Publishes the package route entrypoints.
- Service provider → Allow gate: binds · Makes the access gate available to route middleware.
- Service provider → Explorer controller: wires · Registers the HTTP controller into the package stack.
- Service provider → Install cmd: exposes · Registers install automation commands.
- Service provider → Update cmd: exposes · Registers update automation commands.
- Install cmd → Vite build: publishes · Uses build/package metadata when publishing assets.
- Update cmd → Vite build: refreshes · Relies on the build output and publish flow.
- Web routes → Allow gate: protects · Routes apply the allow-list middleware.
- Web routes → Explorer controller: dispatches · HTTP requests are routed to the explorer controller.
- Allow gate → Config: checks · Reads enablement and environment rules from config.
- Explorer controller → MySQL inspector: reads · Controller delegates schema and row access to the inspector.
- Explorer controller → Column presentation: loads · Reads saved presentation preferences for columns.
- Explorer controller → Type resolver: maps · Converts column metadata into UI control types.
- Explorer controller → Enum extractor: derives · Extracts selectable values for editor controls.
- Column presentation → Presentation migration: stored by · Migration creates the backing table for presentation settings.
- Type resolver → Enum extractor: consults · Type resolution may use enum-derived values.
- Explorer controller → Layout shell: renders · Server-side shell for the explorer pages.
- Layout shell → Tables view: wraps · Layout hosts table-oriented views.
- Layout shell → Schema view: wraps · Layout hosts schema views.
- Layout shell → Table view: wraps · Layout hosts table detail views.
- Tables view → Pagination: includes · Tables view uses pagination partials.
- Vue app → App shell: boots · Entry file initializes the main Vue component.
- App shell → Dashboard: navigates · Root app contains or routes to the dashboard view.
- App shell → Explorer: navigates · Root app contains or routes to the explorer view.
- Explorer → MySQL inspector: consumes · Interactive UI depends on database metadata and rows.
- Explorer → Column presentation: applies · Uses saved presentation settings to render editors.
- Explorer → Type resolver: renders · Uses type mapping to choose controls.
- Explorer → Enum extractor: offers · Populates selectable controls from extracted values.
- Vue app → Explorer CSS: loads · Frontend entry is styled by the distributed CSS.
- Vue app → Explorer bundle: bundles · Entry contributes to the shipped browser bundle.
- Vite build → Vue app: builds · Vite compiles the Vue application.
- Vite build → Explorer CSS: outputs · Build produces the distributed stylesheet.
- Vite build → Explorer bundle: outputs · Build produces the distributable JS bundle.
- Package manifest → Vite build: scripts · Package scripts drive the Vite build.