Download the PHP package vi-kon/laravel-db-exporter without Composer
On this page you can find all versions of the php package vi-kon/laravel-db-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-db-exporter
Database exporter to Laravel 5
This is database table structure and data exporter to migration and seed files for Laravel 5
Table of content
- Features
- Installation
- Configuration
- Usage
- License
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
Installation
Base
To composer.json
file add following lines:
Or run following command in project root:
In Laravel 5 project add following lines to app.php
:
Configuration and migration
Installing configuration and migration files simple run:
Back to top
Configuration
Configuration files help set up default values for commands.
Back to top
Usages
Note: Generated files may need some auto-formatting.
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:
The above command will generate following files into {PROJECT ROOT}/database/migrations
directory:
Note: Table names and column names are converted to snake cased.
Back to top
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:
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:
Back to top
License
This package is licensed under the MIT License
Back to top