Home  >  Q&A  >  body text

How does Laravel generate all command-related files of the model migration controller?

After these commands

php artisan make:model 'FileName' -mcs

Laravel make command file source (model, controller, migration, seeder, factory, etc...)

How are all the basic files generated and where do they come from?

P粉803444331P粉803444331262 days ago469

reply all(2)I'll reply

  • P粉833546953

    P粉8335469532024-01-06 00:56:40

    These files are generated from stub files. Below are some stub directory locations on any Laravel project. You can check this out.

    For models:

    other:

    If you want to control these stubs you must apply the following commands

    This command will publish the stub files in the "stubs" folder of the project directory. You can then customize it to suit your needs.

    reply
    0
  • P粉685757239

    P粉6857572392024-01-06 00:53:05

    Everything generated in Laravel uses templates

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

    If you run this command, it will generate a new folder called Stubs in your application root folder containing a bunch of files with a .stub extension.

    You can open these files and modify or customize them as needed. From now on, your Laravel application will read in this folder templates for making various things that crafters typically make.

    This template is included with every Laravel installation, and publishing them is completely optional. In fact, there are many software packages dedicated to making custom controllers or models, such as this one from Spatie

    Internal structure above the generator Laravel has two cores,

    1. The first in application/console/kernel
    2. The second
    3. in app/Http/kernel

    When you run artisan, Laravel bootstraps the application and runs the kernel console. The two kernels have different purposes and actually run as separate applications.

    Regarding the specific generation of the above files, I mean different controllers, models, migrations, etc. Everything related to the model is generated from a class.

    Class ModelMakeCommand extends GeneratorCommand{ .... }

    Located under the Illuminate\Foundation\Console namespace.

    You can inspect the code for this class and see how the stub files are used to generate only various commands related to the model, but there are many more, such as strategies, events, Homework etc...< /p>

    I hope this helps you and answers your questions

    Here is more information on this topicFrom Laravel News

    reply
    0
  • Cancelreply