Moak Moak - 9 days ago 5
PHP Question

Can one modify the templates created by artisan migrate command?

I've created a base class for my migrations. At the moment I run the artisan migrate command and it creates a new migration that extends the Migrations file, however I want to include my BaseMigration and extend it from there. I've been making this changes manualy but I feel like I'm repeating myself unnecessarily.

Any advice on how to have new migrations automatically extend and load my base migration?

Answer

I don't think you can, because Laravel takes migrations from the vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs folder and you cannot change that, but you have some options:

1) Create your own artisan command migrate:makemyown.

2) Use Jeffrey Way's Laravel 4 Generators. They let you create your migrations by doing:

php artisan generate:migration create_posts_table --fields="title:string, description:text"

If you just have some fields you need to start with and not something more specific than that, it works really fine.

3) Edit Laravel stubs, but the problem is that as soon as you composer update they might get overwritten by Composer.

Comments