2017 © Pedro Peláez
 

library db-exporter

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

image

elimuswift/db-exporter

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

  • Friday, March 9, 2018
  • by weezqyd
  • Repository
  • 3 Watchers
  • 17 Stars
  • 1,415 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 18 Versions
  • 9 % Grown

The README.md

Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Database Exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class. This can be done via artisan commands or a controller action., (*2)

Please note that I've only tested this package on a MySQL database. It has been confirmed it does not work with Postgres, (*3)

Installation

Add "elimuswift/db-exporter"* as a requirement to composer.json:, (*4)

{
    "require": {
        "elimuswift/db-exporter": "*"
    },
}

Update composer:, (*5)

php composer.phar update

For laravel <=5.4, Add the service provider to config/app.php:, (*6)

 Elimuswift\DbExporter\DbExportHandlerServiceProvider::class

(Optional) Publish the configuration file., (*7)

php artisan vendor:publish --provider="Elimuswift\DbExporter\DbExportHandlerServiceProvider"

After publishing the config file make sure you change storage location for migrations and seeds., (*8)

Use dev-master as version requirement to be on the cutting edge, (*9)

Documentation

From the commandline

Export database to migration

Basic usage, (*10)

php artisan db-exporter:migrations

Specify a database, (*11)

php artisan db-exporter:migrations otherDatabaseName

Ignoring tables, (*12)

You can ignore multiple tables by seperating them with a comma., (*13)

php artisan db-exporter:migrations --ignore="table1,table2"

Export database table data to seed class

This command will export all your database table data into a seed class., (*14)

php artisan db-exporter:seeds

Important: This requires your database config file to be updated in config/database.php**, (*15)

Uploading migrations/seeds to Storage Disk

Important: The package backup destinations paths should match your desired disk location, (*16)

You can backup migrations and / or seeds to a storage disk that you application supports., (*17)

php artisan db-exporter:backup --migrations

Or upload the seeds to the production server:, (*18)

php artisan db-exporter:backup --seeds

Or even combine the two:, (*19)

php artisan db-exporter:backup --migrations --seeds

This feature uses Laravel's filesystem., (*20)

You must configure your storage and then specify the disk name in the config file. The default disk is local, (*21)

Export current database

This class will export the database name from your config/database.php file, based on your 'default' option., (*22)

DbExporter::migrate();

Export a custom database

DbExporter::migrate('otherDatabaseName');

Database to seed

This will write a seeder class with all the data of the current database., (*23)

DbExporter::seed();

Seed a custom database

Just pass the nameof the database to be seeded., (*24)

DbExporter::seed('myOtherDB');

Next all you have to do is add the call method on the base seed class:, (*25)

$this->call('nameOfYourSeedClass');

Now you can run from the commmand line:, (*26)

php artisan db:seed, or, without having to add the call method: php artisan db:seed --class=nameOfYourSeedClass, (*27)

Chaining

You can also combine the generation of the migrations & the seed:, (*28)

DbExporter::migrate()->seed();

Or with:, (*29)

DbExporter::migrateAndSeed();

Ignoring tables

By default the migrations table is ignored. You can add tabled to ignore with the following syntax:, (*30)

DbExporter::ignore('tableToIgnore')->migrateAndSeed();
DbExporter::ignore('table1','table2','table3')->migrateAndSeed();

You can also pass an array of tables to ignore., (*31)

From the configuration file

Ignore tables for seeder

If you want to always ignore certain tables you can do it on the config file, (*32)

return [
    'seeds' => [
        'ignore_tables' => [
            'table_to_ignore1',
            'table_to_ignore2'
        ]
    ]
];

With this configuration every time when the command php artisan db-exporter:seeds is executed will ignore the tables on the array, (*33)

Just use selected tables for seeder

In the other hand, If you want to use always certain tables you can do it on the config file, (*34)

return [
    'seeds' => [
        'use_tables' => [
            'table_to_ignore1',
            'table_to_ignore2'
        ]
    ]
];

With this configuration every time when the command php artisan db-exporter:seeds is executed will only be executed to the tables on the array, (*35)

Credits

Credits to @nWidart the original creator of the package DbExporter. I couldn't get it working as-is, so I decided to rewrite the package to fit the latest versions of laravel, and added a couple a features of my own., (*36)

The Versions

09/03 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Master Weez

database laravel migrations php command export artisan seed

09/03 2018

v1.2.4

1.2.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Master Weez

database laravel migrations php command export artisan seed

24/01 2018

v1.2.3

1.2.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Master Weez

database laravel migrations php command export artisan seed

19/10 2017

v1.2.2

1.2.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Master Weez

database laravel migrations php command export artisan seed

06/07 2017

v1.2.1

1.2.1.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

04/07 2017

v1.2.0

1.2.0.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

04/07 2017

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

20/03 2017

v1.1.3

1.1.3.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

20/03 2017

v1.1.2

1.1.2.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

20/03 2017

v1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

28/02 2017

v1.0.9

1.0.9.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

23/02 2017

v1.0.8

1.0.8.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

21/02 2017

v1.0.7

1.0.7.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

14/01 2017

v1.0.6

1.0.6.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

14/12 2016

v1.0.5

1.0.5.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

10/12 2016

v1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

07/12 2016

v1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed

07/12 2016

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Master Weez

database laravel migrations php command export artisan seed