In conclusion, migrating existing PHP applications to laravel can be a challenging task, perticularly when dealing with large databases and tables.
As a developer we need a solution which automates the migration and seeder generation.Thankfully, there are handy packages available to automate the migration and seeder generation processes.
For generating migrations, you can utilize the `kitloong/laravel-migrations-generator` package.
First we will generate migrations from database tables
Run below command
composer require --dev kitloong/laravel-migrations-generatorRunning below command will generate migrations for all tables
php artisan migrate:generateIf you want to create migrations for specific tables then use below command
php artisan migrate:generate --tables="table1,table2,table3"You can also ignore some tables using
php artisan migrate:generate --ignore="table3,table4,table5"Moving on to generating seeders from tables, you can employe the `orangehill/iseed` package. Install it using following command
composer require orangehill/iseedIf you are using Laravel 5.3.7 or below or Laravel 4 then you need to specify iseed version while composer require like this
composer require orangehill/iseed:2.2 # Laravel 5.3.7 and below composer require orangehill/iseed:1.1 # Laravel 4Latest laravel versions set service providers automatically but if you use Laravel 5.4 or below you need to add service provider in
providers array in file app/config/app.php // ...
Orangehill\Iseed\IseedServiceProvider::class,Now run below command using specific table names for generating seeders for each table
php artisan iseed table1,table2,table3You can use
--force to force an existing seeder to re generatephp artisan iseed users --forceBy automating the migration and seeder generating processes, these packages save developers significant time and effort. Give them a try and streamline your Laravel application development experience. Happy coding!
Comments
Post a Comment