In the HLEB2 framework, when creating Models, Controllers, and entire modules, you can use special console commands. Additionally, the initial file templates are customizable according to the developer's own preferences.
Console command to generate a Controller class:
$php console --add controller Demo/ExampleController
The command will create the file /app/Controllers/Demo/ExampleController.php with the new Controller class.
To change the template for creating a class, copy the file 'controller_class_template.php' from '/vendor/phphleb/framework/Optional/Templates/' to the folder '/app/Optional/Templates/' and make the necessary modifications.
Console command to generate new middleware:
$php console --add middleware Demo/ExampleMiddleware
After execution, the file /app/Middlewares/Demo/ExampleMiddleware.php with the middleware class will be created.
To modify the original middleware template, copy the file 'middleware_class_template.php' from '/vendor/phphleb/framework/Optional/Templates/' to the folder '/app/Optional/Templates/', and then make changes.
Example of creating a Model class from the console:
$php console --add model Demo/ExampleModel
This command will create the file /app/Models/Demo/ExampleModel.php with the Model class.
To change the original template for the Model, copy the file 'model_class_template.php' from '/vendor/phphleb/framework/Optional/Templates/' to the folder '/app/Optional/Templates/' and edit it as needed.
Console command to create a new task, specifying the task name:
$php console --add task demo/example-task
Upon execution, the file app/Commands/Demo/ExampleTask.php will be created.
To make changes to the base class, copy the file 'task_class_template.php' from '/vendor/phphleb/framework/Optional/Templates/' to the folder '/app/Optional/Templates/' and adjust it as needed.
To generate the base files for a Module in the 'modules' directory (the name can be changed in the settings), execute the following command:
$php console --create module main
Where 'main' is the name of the new module. For a nested module in the 'modules/demo' folder, modify the command as follows:
$php console --create module demo/main
If you need to create your own module template files, copy the contents of the directory '/vendor/phphleb/framework/Optional/Modules/example/' to the folder '/app/Optional/Modules/example/' and make the necessary changes to the files.
When modifying the base files, keep in mind that special tags are included, and they are necessary for the correct substitution of console parameters.