PHPackages                             hadeluca/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. hadeluca/db-exporter

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

hadeluca/db-exporter
====================

this is a package for Laravel Framework to export, via command line, Database in Migration and all data in a Seed

v2.5.0(4y ago)41.1k11MITPHP

Since Jun 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Hertox82/hardel-Laravel-DbExporter)[ Packagist](https://packagist.org/packages/hadeluca/db-exporter)[ RSS](/packages/hadeluca-db-exporter/feed)WikiDiscussions 2.5 Synced 3d ago

READMEChangelogDependencies (9)Versions (15)Used By (1)

Hardel-Laravel-Exporter
=======================

[](#hardel-laravel-exporter)

Export your database quickly and easily as a Laravel Migration (for the structure) and all the data as a Seeder class.

This can be done via artisan commands or a controller action.

This package is a restructuring of the existing [nWidart/DbExporter](https://github.com/nWidart/DbExporter) library

Hardel ExporterLaravel Supported versionMaatWebsite2.0.\*5.4.+, 5.5.+2.1.282.1.\*5.5.+, 5.6.+2.1.282.2.\*&gt;=5.5 &lt;=5.8.\*3.1.\*2.3.\*^6.203.1.\*2.4.\*^7.293.1.\*2.5.\*^8.403.1.\*PS: When you update the library, please remember to re-publish vendor!

Changelog
---------

[](#changelog)

see the [Changelog](CHANGELOG.md) file *(created with version 2.3.0)*

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

[](#installation)

Add `"hadeluca/db-exporter"`\* as a requirement to `composer.json`:

```
{
    ...
    "require": {
        ...
        "hadeluca/db-exporter": "2.5.*"
    },
}
```

Update composer:

```
php composer.phar update
```

or via command line:

```
composer require hadeluca/db-exporter
```

Add the service provider to `app/config/app.php`:

```
'Hardel\Exporter\DBExporterServiceProvider::class'
```

(Optional) Publish the configuration file.

```
php artisan vendor:publish hadeluca/db-exporter
```

*Use `dev-master` as version requirement to be on the cutting edge*

Documentation
-------------

[](#documentation)

### From the commandline

[](#from-the-commandline)

#### Export database to migration

[](#export-database-to-migration)

##### Basic usage

[](#basic-usage)

```
php artisan dbexp:migration
```

##### Specify a database

[](#specify-a-database)

```
php artisan dbexp:migration databaseName
```

##### Ignoring tables

[](#ignoring-tables)

You can ignore multiple tables by seperating them with a comma.

```
php artisan dbexp:migration --ignore="table1,table2"
```

#### Export database table data to seed class

[](#export-database-table-data-to-seed-class)

This command will export all your database table data into a seed class.

```
php artisan dbexp:seed
```

Also here you can ignore multiple tables:

```
php artisan dbexp:seed --ignore="table1,table2"
```

*Important: This **requires your database config file to be updated in `config/database.php`**.*

Next all you have to do is add the call method on the base seed class in `database/seeds/DatabaseSeeder.php`:

```
$this->call('nameOfYourSeedClass');
```

Now you can run from the commmand line:

- `php artisan db:seed`,
- or, without having to add the call method: `php artisan db:seed --class=nameOfYourSeedClass`

#### Chaining

[](#chaining)

You can also combine the generation of the migrations &amp; the seed:

```
php artisan dbexp:all [databaseName] [--ignore="table1,table2"]
```

#### Ignoring tables

[](#ignoring-tables-1)

By default the migrations table is ignored.

### Export all data in .xlsx (Excel)

[](#export-all-data-in-xlsx-excel)

Now you can export all data in excel file from the command line

```
php artisan dbexp:excel-data [databaseName] [path] [--ignore="table1,table2"]
```

by default (in config.php) you can find the path where the library store the database.xlsx

```
