0

after these commands

php artisan make:model 'FileName' -mcs

Laravel make command files sources (Model, Controller, Migration, Seeder, Factory etc...)

How all basic files generate and where from these files comes?

shaedrich
  • 5,457
  • 3
  • 26
  • 42
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 14 '22 at 07:24

2 Answers2

2

All the generated stuff in Laravel use templates

If you run artisan command in your console, you can observe that exists a section called stub, and the only command in this section is php artisan stub:publish.

If you run that command it will generate a new folder inn your app root folder called stubs with a bunch of files inside all with extension .stub.

You can open those files and modify then or customize them as needed. From now on this folder will be the place from where your Laravel app will read the template for making all kind of stuff that artisan usually does.

This templates are included with every Laravel installation and is totally optional publish them or not. In fact there are many packages dedicated to make custom Controllers or Models like this one from Spatie

The internals above this generators Laravel has two kernels,

  1. The first one in app/Console/kernel
  2. The second one in app/Http/kernel

When you run artisan, Laravel Bootstrap the app, and run the Kernel console. This both Kernels has different purposes, really they function as separates apps.

About the specific generation of the above files, I mean different controllers, Models, migrations etc.. all that stuff related to models are generated by one Class.

class ModelMakeCommand extends GeneratorCommand{ .... }

Which is located under Illuminate\Foundation\Console namespace.

You can check the code of that class and see how the stubs files are used to generate the variety of commands only related to Models, but there are many more, like Policies, Events, Jobs etc...

I hope this helps and answer your question

Here you are more information about this subject from Laravel News

Manuel Glez
  • 890
  • 3
  • 12
0

These files are being generated from stub files. Here are some stubs directory location on any laravel project. you can check this out.

For Model :

vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/model.stub

Others :

vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs vendor/laravel/framework/src/Illuminate/Routing/Console/stubs vendor/laravel/framework/src/Illuminate/Database/Console/Factories/stubs vendor/laravel/framework/src/Illuminate/Database/Console/Seeds/stubs

if you want control over these stubs you have to apply below command

php artisan stub:publish

this command will publish stub files on "stubs" folder on your project directory. Then you can customize according to your need.

AL-IMRAN
  • 106
  • 2