| Package Data | |
|---|---|
| Maintainer Username: | autn |
| Maintainer Contact: | autk08@gmail.com (Au Truong Ngoc) |
| Package Create Date: | 2016-05-11 |
| Package Last Update: | 2020-09-16 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-07 03:04:07 |
| Package Statistics | |
|---|---|
| Total Downloads: | 3,762 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 5 |
| Total Watchers: | 1 |
| Total Forks: | 8 |
| Total Open Issues: | 2 |
This package generate Mysql database schema from migrations files.
Install via composer - edit your composer.json to require the package.
"require": {
// ...
"autn/laravel-schema": "*"
}
Then run composer update in your terminal to pull it in.
Once this has finished, you will need to add the command to the commands array in your app/Console/Kernel.php config as follows:
// ....
protected $commands = [
// ...
'db:schema' => \Autn\Schema\Console\Commands\DumpSql::class,
];
// ...
Notice: The command will refresh your database, the seeding and actual datas will remove. I recommend use --dbconnect to run with other database.
In root Laravel project, type:
php artisan db:schema
The file will generate to the default databases path (database/schema.sql).
You can change this path by add --path option to the command.
Example:
php artisan db:schema --path=public
The default database connect is mysql in config/database.php. You can change the connect by add --dbconnect to the command.
Example:
php artisan db:schema --path=public --dbconnect=mysql2
Notice: If you add --dbconnect option, you must add config to config/database.php.
Example:
// ....
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'db'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'mysql2' => [
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'database' => 'db2',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
// ...
There are full options:
--path=: Path to save schema file
--dbconnect=: Database connect to run
--force: Run without confirmation
--method=: Name of method (mysqldump/php). If your server not install mysql (remote to other database server), you must select `php` method
--refresh=: Public migration files and refresh migrations (yes/no)
--type=: Type of file (sql/gzip/bzip2)
Supported mysqldump method
Supported php method (mysqldump version php)
Supported compress (type option)