Skip to content
laranailPublic

About

Standalone Laravel database utilities: UUID/ULID traits, schema macros, soft-archive, casts, and backup/restore.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

laranail/db-tools

Tests Static analysis License: MIT

laranail/db-tools is not published to Packagist, so there is no registry-version badge to show: see Install.

Independent, framework-agnostic database utilities for Laravel — model traits (UUID/NanoID/ULID keys, JSON accessors, slugs, soft-archiving, inheritance-friendly fillable/hidden/casts/defaults), money & datetime casts, schema macros, an audit observer, backup/restore, a database CLI, cursor/offset pagination, and inspection services.

PHP ^8.4.1 || ^8.5 on Laravel ^13. Its only Laranail dependency is laranail/package-tools, which builds its service provider.

Install

The package is not on Packagist. Add its VCS repositories, and laranail/package-tools, which it requires, to your application's composer.json (Composer reads repositories only from the root package):

"repositories": [
    { "type": "vcs", "url": "https://github.com/laranail/db-tools" },
    { "type": "vcs", "url": "https://github.com/laranail/package-tools" },
    { "type": "composer", "url": "https://repo.packagist.org", "exclude": ["laranail/*"] },
    { "packagist.org": false }
]
composer require laranail/db-tools:^0.1

DbToolsServiceProvider is auto-discovered and registers the schema macros at boot.

Quick start guide and usage

Getting started

Nothing is required: the defaults work as installed. Two optional steps:

  1. Publish the config to tune the key type, audit columns, money currency and backup behaviour:

    php artisan vendor:publish --tag=laranail::db-tools-config
  2. If you use the soft-delete restore history, publish its migration and run it:

    php artisan vendor:publish --tag=laranail::db-tools-migrations
    php artisan migrate

Usage

use Simtabi\Laranail\DbTools\DbTools;

DbTools::testConnection();                                   // true
DbTools::getDriver();                                        // 'pgsql'
DbTools::getMissingTables(['users', 'orders', 'invoices']);  // ['invoices']
DbTools::backup(storage_path('backups/nightly.sql'));        // true

The schema macros are available in any migration:

Schema::create('orders', function (Blueprint $t): void {
    $t->id();
    $t->auditColumns();        // created_by, updated_by, deleted_by
    $t->softDeletesWithUndo(); // deleted_at + restored_at
    $t->timestamps();
});

The full API is in The DbTools facade; everything else is in the documentation index.

Documentation

Full documentation is at opensource.simtabi.com/documentation/laranail/db-tools.

Guides

Reference

Contributing & security

Issues and PRs are welcome — see CONTRIBUTING.md. Report vulnerabilities per SECURITY.md (security@simtabi.com); participation follows the Code of Conduct.

License

MIT © Simtabi LLC. See LICENSE.

About

Standalone Laravel database utilities: UUID/ULID traits, schema macros, soft-archive, casts, and backup/restore.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages