| Package Data | |
|---|---|
| Maintainer Username: | Schwarzer IT |
| Maintainer Contact: | andre@schwarzer.it (André Schwarzer) |
| Package Create Date: | 2016-02-01 |
| Package Last Update: | 2018-09-25 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-06 15:02:36 |
| Package Statistics | |
|---|---|
| Total Downloads: | 8,543 |
| Monthly Downloads: | 1 |
| Daily Downloads: | 0 |
| Total Stars: | 13 |
| Total Watchers: | 4 |
| Total Forks: | 3 |
| Total Open Issues: | 0 |
I was in need of a tool to export Data from an existing MySQL DB to a Laravel Seeder. I searched online for it, but found not the right tool I wanted. I stumbled upon the namelivia/mysql-to-laravel-seed.
But it ...
use Illuminate\Database\Seeder;)I decided to create my own version of a MySQL to Laravel Seeder Tool.
| PHP Version | MySQL Version | |-------------|---------------| | 5.6.17 | 5.6.25 | | 5.6.17 | 5.7.10 | | 7.0.2 | 5.6.25 | | 7.0.2 | 5.7.10 |
I welcome all notifications about working environments. Just mail me (info@schwarzer.it) and I'll put it up here, or send a merge request.
Create a file named export.php in your Laravel root (where your .env is) and execute it by using php ./export.php . Done.
<?php
require_once __DIR__.'/path/to/schwarzer/laravel-mysql-to-seeder/src/Export.php';
$export = new \Schwarzer\LaravelHelper\MySQLToSeeder\Export('hostname','database','username','password',3306);
$export->generateExport(
null, // null equals "All Tables" ( $this->getAllTableNames() )
'./database/seeds', // if null './database/seeds' is applied
['these','are','boolean','values'],
['timestamp_column','created_at', 'updated_at'],
['type','date']
);
<?php
require __DIR__.'/vendor/autoload.php';
$export = new \Schwarzer\LaravelHelper\MySQLToSeeder\Export('hostname','database','username','password',3306);
$export->generateExport(
null, // null equals "All Tables" ( $this->getAllTableNames() )
'./database/seeds', // if null './database/seeds' is applied
['these','are','boolean','values'],
['timestamp_column','created_at', 'updated_at'],
['type','date']
);