Skip to content

thedevdojo/database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevDojo Database

Latest Version on Packagist Total Downloads GitHub Actions

A Livewire-powered database browser for Laravel. Lists your application's tables and lets you search, sort, paginate, and edit records inline — two drop-in components, styled with Tailwind, that work against any table in your default database connection.

This is the package behind the /database inspector page in DevDojo Platform apps, but it is a standalone utility you can mount in any Laravel + Livewire application.

What you get

Two Livewire components that talk to each other:

  • devdojo.tables — the table list. Shows every table in your database (minus the excluded ones), with instant client-side filtering and configurable pinned ordering. Clicking a table tells the browser component to load it.
  • devdojo.database — the record browser for the selected table:
    • Search across all columns (or a configured subset per table), debounced as you type.
    • Sort by any column — click a header to sort, click again to flip direction. The default sort column is the table's primary key.
    • Paginate — 15 rows per page by default (the component's public $paginate property).
    • Edit inline — clicking a row opens a slide-over editor with one field per column. Saving writes only the columns you changed, then shows a "Saved successfully" toast.

Rows are addressed by the table's single-column primary key, which the package detects from the schema (it doesn't have to be id). Tables without one — composite-key pivots, for example — are still browsable, but read-only.

A small support class, DevDojo\Database\Support\TableManager, powers both components and is resolvable from the container if you need the same table/column/primary-key introspection in your own code (tableNames(), tables() with row counts, columns(), primaryKey()).

Requirements

  • PHP 8.3+
  • Laravel 11+
  • Livewire 3+ in the host application (Alpine is bundled with Livewire)
  • Tailwind CSS in your build (see Styling)

Installation

You can install the package via composer:

composer require devdojo/database

The service provider is auto-discovered and registers both components — there are no migrations and no routes. Optionally publish the config:

php artisan vendor:publish --tag=devdojo-database-config   # → config/devdojo-database.php

Usage

Drop the Livewire components onto any page:

@livewire('devdojo.tables')
@livewire('devdojo.database')

A typical layout puts devdojo.tables in a sidebar and devdojo.database in the main pane — they communicate through Livewire events, so they don't need to share a parent component. Both default to the users table; pass a different starting table if you want:

@livewire('devdojo.database', ['table' => 'posts'])

Protect the page. The components read and write your database directly and enforce no authorization of their own — mount them behind whatever auth, middleware, or environment gating your app requires.

Configuration

config/devdojo-database.php:

Key What it does Default
table-exclude Tables hidden from the browser. migrations, password_reset_tokens, sessions, cache, cache_locks, jobs, job_batches, failed_jobs
table-order Tables pinned to the top of the list, in order. ['users']
searchable Optional per-table searchable columns, e.g. 'users' => ['name', 'email']. Tables not listed fall back to searching all of their columns. []

Styling

The component views are built with Tailwind utility classes, so your build needs to scan the package's views for classes to compile.

Tailwind v4 — add to your CSS entry:

@source "../../vendor/devdojo/database/src/**/*.blade.php";

Tailwind v3 — add to tailwind.config.js:

content: [
    // ...
    './vendor/devdojo/database/src/**/*.blade.php',
],

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email tony@devdojo.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

The Database package for the DevDojo Platform

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages