laravel-file-generator icon indicating copy to clipboard operation
laravel-file-generator copied to clipboard

Allow multiple output files per boilerplate

Open vpratfr opened this issue 7 years ago • 6 comments

This would allow one command to generate multiple files (e.g. for the view composers, optionally generate the associated service provider if not already existing based on a flag)

vpratfr avatar Apr 13 '17 14:04 vpratfr

Other example :

  • Could generate a model file + associated TestCase + associated migration + etc.
  • Generate a PHP interface + base implementation of that interface in same folder
  • etc.

vpratfr avatar Apr 13 '17 14:04 vpratfr

I tried doing this. The problem is having a nice syntax to chain them all together became quite tricky.

Instead now I use a bash function to call multiple ones. For example, I make a model and add a new repository for the model (repository boilerplate is specific to my project so it isn't here)


function make_model () {
  php artisan make:model -m $1
  php artisan generate repo "$1" 
}

$ make_model Car
# Creates file app/Car.php
# Creates file app/Repositories/CarRepository.php

If you have a suggestion on how this can be accomplished with syntax i'm all ears 😄

skyronic avatar Apr 13 '17 16:04 skyronic

You must split the boilerplate "manifest" (JSON part) from the boilerplate "templates" (Blade part). That way you are free to specify multiple templates in your manifest.

vpratfr avatar Apr 14 '17 10:04 vpratfr

You could have for instance a more structured hierarchy:

boilerplates/php__class/manifest.json
boilerplates/php__class/template-1.blade.php
boilerplates/php__class/template-2.blade.php

vpratfr avatar Apr 14 '17 10:04 vpratfr

The big benefit is that now PHP Storm will allow syntax highlighting on the template files, JSON checking, etc. Which was not available when mixing both languages in a single file.

Once you fix that current limitation, you'll be able to move on to something more advanced.

vpratfr avatar Apr 14 '17 10:04 vpratfr

This sounds really interesting. Is there anything new on creating multiple files?

KuenzelIT avatar Jun 11 '18 13:06 KuenzelIT

Hi. Will be closing this for housekeeping. Sorry about the lack of updates.

skyronic avatar Nov 21 '22 22:11 skyronic