PHPackages                             vi-kon/laravel-db-exporter - 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. [Database &amp; ORM](/categories/database)
4. /
5. vi-kon/laravel-db-exporter

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

vi-kon/laravel-db-exporter
==========================

Database table structure and data exporter to migration and seed files

v1.0(11y ago)1038.4k↓66.4%5[5 issues](https://github.com/vi-kon/laravel-db-exporter/issues)MITPHPPHP &gt;=5.4.0

Since Mar 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/vi-kon/laravel-db-exporter)[ Packagist](https://packagist.org/packages/vi-kon/laravel-db-exporter)[ RSS](/packages/vi-kon-laravel-db-exporter/feed)WikiDiscussions develop Synced 2d ago

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

Database exporter to Laravel 5
==============================

[](#database-exporter-to-laravel-5)

This is database table structure and data exporter to migration and seed files for **Laravel 5**

Table of content
----------------

[](#table-of-content)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [License](#license)

Features
--------

[](#features)

- create **migration** files from database table structure
- handle foreign keys (watch for recursive foreign keys)
- create **model** files from database table structure (even foreign keys)
- **organize** generated models depending on database tabla name to **individual namespace** and **directory** structure via regular expressions
- create **seed** files from database table content

---

[Back to top](#database-exporter-to-laravel-5)

Installation
------------

[](#installation)

### Base

[](#base)

To `composer.json` file add following lines:

```
// to "require" object
"vi-kon/laravel-db-exporter": "~1.*"
```

Or run following command in project root:

```
composer require vi-kon/laravel-db-exporter
```

In Laravel 5 project add following lines to `app.php`:

```
// to providers array
'ViKon\DbExporter\DbExporterServiceProvider',
```

### Configuration and migration

[](#configuration-and-migration)

Installing configuration and migration files simple run:

```
php artisan vendor:publish --provider="ViKon\DbExporter\DbExporterServiceProvider"
```

---

[Back to top](#database-exporter-to-laravel-5)

Configuration
-------------

[](#configuration)

Configuration files help set up default values for commands.

```
return [
    /*
    | --------------------------------------------------------------------------
    | Default connection name
    | --------------------------------------------------------------------------
    | Database connection name. Valid connection names are defined in
    | database.php. If value is null default connection is used.
    |
    */
    'connection' => null,
    /*
    | --------------------------------------------------------------------------
    | Default table prefix
    | --------------------------------------------------------------------------
    | This table prefix is used in generated migration files or in generated
    | models.
    |
    */
    'prefix'     => '',
    /*
    | --------------------------------------------------------------------------
    | Default selected tables
    | --------------------------------------------------------------------------
    | Select specified database tables only. No work with ignore option
    | together. In commands with --select option can add another tables.
    |
    */
    'select'     => [],
    /*
    | --------------------------------------------------------------------------
    | Default ignored tables
    | --------------------------------------------------------------------------
    | Ignore specified database tables. No work with select option together.
    | In commands with --ignore option can add another tables.
    |
    */
    'ignore'     => [
        'migrations',
    ],
    /*
    | --------------------------------------------------------------------------
    | Model options
    | --------------------------------------------------------------------------
    */
    'model'      => [
        /*
        | --------------------------------------------------------------------------
        | Default namespace
        | --------------------------------------------------------------------------
        | Namespace for generated models. In command with --namespace option can
        | overwrite.
        |
        */
        'namespace' => 'App\Models',
        /*
        | --------------------------------------------------------------------------
        | Default path
        | --------------------------------------------------------------------------
        | Generated models destination path. Is relative to projects base path. In
        | command with --path option can overwrite.
        |
        */
        'path'      => app_path('Models'),
        /*
        | --------------------------------------------------------------------------
        | Custom map
        | --------------------------------------------------------------------------
        | Map is useful for organizing generated models to multiple namespaces and
        | directories. Each map entry is array with following associative keys:
        |
        | * tablePattern - regex pattern for selecting tables by name
        | * namespace    - generated models namespace from selected tables
        | * path         - generated models destination path from selected tables
        | * className    - array containing pattern and replacement for preg_match
        |                  to generate models class name from table name. If value
        |                  is null original table name is used. The result is camel
        |                  cased. The subject table name is snake cased
        |
        */
        'map'       => [
//            [
//                'tablePattern' => '.*',
//                'namespace'    => 'App\Models',
//                'path'         => 'app/Models',
//                'className'    => [
//                    'pattern'     => '',
//                    'replacement' => '',
//                ],
//            ],
        ],
    ],
    /*
    | --------------------------------------------------------------------------
    | Migration options
    | --------------------------------------------------------------------------
    */
    'migration'  => [
        /*
        | --------------------------------------------------------------------------
        | Default path
        | --------------------------------------------------------------------------
        | Generated migration destination path. Is relative to projects base path.
        | In command with --path option can overwrite.
        |
        */
        'path' => base_path('database/migrations'),
    ],
    /*
    | --------------------------------------------------------------------------
    | Seed options
    | --------------------------------------------------------------------------
    */
    'seed'       => [
        /*
        | --------------------------------------------------------------------------
        | Default path
        | --------------------------------------------------------------------------
        | Generated seed destination path. Is relative to projects base path.
        | In command with --path option can overwrite.
        |
        */
        'path' => base_path('database/seeds'),
    ],
];
```

---

[Back to top](#database-exporter-to-laravel-5)

Usages
------

[](#usages)

**Note**: Generated files may need some auto-formatting.

### Creating migration files

[](#creating-migration-files)

The `db-exporter:migrate` command is used for creating migration files from database. It has several options:

- **prefix** - database name prefix in migration files
- **select** - array of selected database table names (if set `ignore` option is ignored)
- **ignore** - array of ignored database table names
- **database** - specify database connection name (if option is not set the default connection is used)
- **force** - force overwriting existing migration files
- **path** - output destination path relative to project root (default is `{PROJECT ROOT}/database/migrations`)

**Note**: Model path given by `migration.path` config key have to be writable by PHP to generate models.

The example assumes following database tables:

- **users**
- **groups**
- **pages** with foreign key to user id

Exports all tables from default database:

```
php artisan db-exporter:migrate
```

The above command will generate following files into `{PROJECT ROOT}/database/migrations` directory:

```
YYYY-MM-DD_000000_create_users_table.php
YYYY-MM-DD_000001_create_groups_table.php
YYYY-MM-DD_000002_create_pages_table.php
```

**Note**: Table names and column names are converted to snake cased.

---

[Back to top](#database-exporter-to-laravel-5)

### Creating models

[](#creating-models)

The `db-exporter:models` command is used for creating models from database. It has several options:

- **prefix** - database name prefix in migration files
- **select** - array of selected database table names (if set `ignore` option is ignored)
- **ignore** - array of ignored database table names
- **connection** - specify database connection name (if option is not set the default connection is used)
- **force** - force overwriting existing migration files
- **namespace** - models namespace (default is `App\Models`)
- **path** - output destination path relative to project root (default is `{PROJECT ROOT}/database/migrations`)

**Note**: Some situation foreign methods name can match in models, so manual renaming is needed.

**Note**: In some cases relation guess (`One to One`, `Many to One`, `One to Many`) can generate same method names in single class.

**Note**: Model path given by `model.path` config key have to be writable by PHP to generate models.

Creating models from default database:

```
php artisan db-exporter:models
```

### Creating seed files

[](#creating-seed-files)

The `db-exporter:seed` command is used for creating seeds from database data. It has several options:

- **prefix** - database name prefix in migration files
- **select** - array of selected database table names (if set `ignore` option is ignored)
- **ignore** - array of ignored database table names
- **connection** - specify database connection name (if option is not set the default connection is used)
- **force** - force overwriting existing migration files
- **path** - output destination path relative to project root (default is `database/seeds`)

**Note**: Seed path given by `seed.path` config key have to be writable by PHP to generate seed classes.

Creating seed files from default database:

```
php artisan db-exporter:seed
```

---

[Back to top](#database-exporter-to-laravel-5)

License
-------

[](#license)

This package is licensed under the MIT License

---

[Back to top](#database-exporter-to-laravel-5)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

4122d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97ac6badd847093e56369390bf36ddbb8740e10a8a495b339c2adb78e7345663?d=identicon)[vincekovacs](/maintainers/vincekovacs)

---

Top Contributors

[![vincekovacs](https://avatars.githubusercontent.com/u/1031595?v=4)](https://github.com/vincekovacs "vincekovacs (42 commits)")

---

Tags

laravelmigrationdatabaseexporterseeder

### Embed Badge

![Health badge](/badges/vi-kon-laravel-db-exporter/health.svg)

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8465.5M96](/packages/laravel-doctrine-orm)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

166251.3k1](/packages/cybercog-laravel-clickhouse)[awssat/laravel-sync-migration

Laravel tool helps to sync migrations without refreshing the database

10823.4k](/packages/awssat-laravel-sync-migration)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3422.6k](/packages/dragon-code-laravel-data-dumper)

PHPackages © 2026

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