PHPackages                             vizrex/laravel-db-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. vizrex/laravel-db-utils

ActiveLaravel-package[CLI &amp; Console](/categories/cli)

vizrex/laravel-db-utils
=======================

This package provides command line utilities for database related operations like create, backup and restore.

1.0.1(6y ago)1441proprietaryPHP

Since Jan 16Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Vizrex/laravel-db-utils)[ Packagist](https://packagist.org/packages/vizrex/laravel-db-utils)[ RSS](/packages/vizrex-laravel-db-utils/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (4)Used By (0)

> # READ THIS FIRST
>
> [](#read-this-first)
>
> It is highly recommended for all contributors to update this file whenever there's a major update in source code. Use [this tool](https://stackedit.io/app#) for easy editing or [visit this page](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for comprehensive guide on markdown syntax.

Introduction
============

[](#introduction)

This package contains command line utilities for database operations like backup, restore and create.

Dependencies
============

[](#dependencies)

The following packages are used as dependencies:

- Laravel Dotenv Editor ()
- Laravel Dropbox Driver ()
- Filesystem Adapter for Google Drive ()

Configuration
=============

[](#configuration)

- Publish the configuration using command `php artisan vendor:publish --provider='Vizrex\LaravelDbUtils\LaravelDbUtilsProvider'`
- This will publish `dbutils.php` to `config/`
- In `dbutils.php`, you can set default behaviour for included command line utilities.
- Add the following sections in `disks` array in your `config/filesystems`

    ```
      'dropbox' => [
          'driver' => 'dropbox',
          'token' => env('DROPBOX_TOKEN'),
      ],

      'google' => [
          'driver' => 'google',
          'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
          'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
          'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
          'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
      ],

    ```

    You also need to add these variables in .env with their values.

    ```
      DROPBOX_TOKEN=xxxxxxx

      GOOGLE_DRIVE_CLIENT_ID=xxxxxxxxxx
      GOOGLE_DRIVE_CLIENT_SECRET=xxxxxxxxxx
      GOOGLE_DRIVE_REFRESH_TOKEN=xxxxxxxxxx
      GOOGLE_DRIVE_FOLDER_ID=xxxxxxxxxx

    ```
- This will be used to upload database backup file to dropbox and google drive.
- This gist is helpful for getting google drive credentials

Console Commands
================

[](#console-commands)

db:backup
---------

[](#dbbackup)

### Description

[](#description)

A console command to backup the application's default mysql database. the following config variables are used to backup the database:

- `database.connections.mysql.database`
- `database.connections.mysql.username`
- `database.connections.mysql.password`

### Signature

[](#signature)

`db:backup  {--path= : The path to save the backup file.} {--ignore_tables= : Comma separated list of tables that should not be included in backup} {--compress= : Whether to compress the backup file. It accepts true or false} {--upload= : Whether to upload the backup file to Dropbox and Google Drive. It accepts true or false}                 `

- If `--path` is not provided, then default path will be used. Default path can be configured in `config/dbutils.php` as `backup.path`
- If `--compress` is not provided, default value will be used which can be configured in `config/dbutils.php` as `backup.compress`
- If `--upload` is not provided, default value will be used which can be configured in `config/dbutils.php` as `backup.upload`

### Usage Examples

[](#usage-examples)

- `php artisan db:backup`
- `php artisan db:backup --path=/backups/ --compress=true`
- `php artisan db:backup --upload=true`
- `php artisan db:backup path= /backups/ --ignore_tables=cities,vehicles,invoices --upload=true --compress=true`

db:restore
----------

[](#dbrestore)

### Description

[](#description-1)

This command is used to resotre a database from given file. This command uses following config variables to determine which database to restore to.

- `database.connections.mysql.database`
- `database.connections.mysql.username`
- `database.connections.mysql.password`
- `database.connections.mysql.host`

### Signature

[](#signature-1)

`db:restore {path}`

### Usage Example

[](#usage-example)

`db:restore /backups/2018_08_03_12_12_42_726150_db_project.sql`

db:create
---------

[](#dbcreate)

### Description

[](#description-2)

This command is used to create a database for the application. It can also create a new user, give that user the previllages for newly created database and set database variables in .env

### Signature

[](#signature-2)

`db:create {new_database : name for the database to be created}`
`{username : A username that has CREATE TABLE privileges}`
`{--password= : Password for the user}`
`{--host= : Database host.}`
`{--port= : Database port.}`
`{--new_user= : If provided, a new user will be created and will be granted database privileges}`
`{--new_password= : Password for the new user}`
`{--set_env=true: Whether to write database variables to .env . It accepts true or false, default is true}`

#### Default configuration:

[](#default-configuration)

- `create` array in `config/dbutils.php` is used to set default values for host and port options.

### Usage Examples

[](#usage-examples-1)

- `php artisan db:create db_shop_mgmt --username=root --password=root`
- `php artisan db:create db_shop_mgmt --username=root --password=root --new_user=user123 --new_password=12345678`
- `php artisan db:create db_shop_mgmt --username=root --password=root --new_user=user123 --new_password=12345678 --set_env=false`

### Note:

[](#note)

- Database charset will be utf8mb4 and collation will be set to utf8mb4\_unicode\_ci

- if `--set_env` is true, the following variables in .env will be set:
    - DB\_DATABASE
    - DB\_HOST
    - DB\_PORT
    - DB\_USERNAME
    - DB\_PASSWORD

Backup of .env will be automatically stored at `storage/dotenv-editor/backups/` before new values are written.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~167 days

Total

2

Last Release

2503d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49ed679f8af1a3a1da9a187d1ce6520287263a4d1c575617708fc76cbcff3ba4?d=identicon)[vizrex](/maintainers/vizrex)

---

Top Contributors

[![nafeeshasan](https://avatars.githubusercontent.com/u/42134152?v=4)](https://github.com/nafeeshasan "nafeeshasan (11 commits)")[![zeshanfarooqi](https://avatars.githubusercontent.com/u/1576772?v=4)](https://github.com/zeshanfarooqi "zeshanfarooqi (11 commits)")

### Embed Badge

![Health badge](/badges/vizrex-laravel-db-utils/health.svg)

```
[![Health](https://phpackages.com/badges/vizrex-laravel-db-utils/health.svg)](https://phpackages.com/packages/vizrex-laravel-db-utils)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
