nachofassini / laravel-database-structure by nachofassini

Package that generates a php file with the tables and fields of the database after running all the migrations
3,723
1
2
Package Data
Maintainer Username: nachofassini
Maintainer Contact: nachofassini@gmail.com (Ignacio Fassini)
Package Create Date: 2017-07-25
Package Last Update: 2018-05-17
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:06:11
Package Statistics
Total Downloads: 3,723
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Package that generates a schema file

Install

You can pull in the package via composer:

    composer require nachofassini/laravel-database-structure

For laravel < 5.6: the service provider must be registered:

    // config/app.php
    'providers' => [
        ...
        NachoFassini\LaravelDatabaseStructure\ServiceProvider::class,
        
    ];

How to generate schema file

To generate schema file just type in the console:

    php artisan schema:file

The file should be generated at your database path like schema.php and would look like these:

    $tables => [
        'users' => [
            'id',
            'name',
            'email',
            'created_at',
            ...
        ],
        'posts' => [
            'user_id',
            'title',
            ...
        ]
    ];

There are no conventions about this, but I think this file should be ignored.

Automatic update on migrations

If you want the file to be updated every time you change the database through any migrate command, just set AUTOMATIC_SCHEMA_FILE=true in your .env file.

This will make that after executing any kind of migration command, the schema file gets up to date with the final database structure.

Contributing

I think this can be much more useful, any collaboration is appreciated.

License

The MIT License (MIT). Please see License File for more information.