laravel-file-generator
laravel-file-generator copied to clipboard
Allow multiple output files per boilerplate
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)
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.
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 😄
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.
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
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.
This sounds really interesting. Is there anything new on creating multiple files?
Hi. Will be closing this for housekeeping. Sorry about the lack of updates.