In order to create new templates you just need to do the following.
- Create new folder with your
templateName
into thetemplates
folder. - Create you template files under your new template.
- Set your placeholders:
- Placeholders must have the following format
${param_name}
- Placeholders are possible on files content as well as on folder/file names.
- Placeholders must have the following format
- Create a new folder called
.no-copied-config
into you template - Add there a description.txt file with a short description that clarifies what the template is for:
- This description will be show when running
./mg2-codegen.phar template:info <template>
- This description will be show when running
-
If your template requires some manual steps after the code is generated, you can document this info in:
.no-copied-config/after-generate-info.txt
- This info will be displayed at the end of the code generation command. You can also use placeholders on this file.
-
If you want that your template executes other templates before, you can set dependencies in:
-
.no-copied-config/config.yml
dependencies: 0: <template-name> 1: <template-name>
-
You can check a template example here Template Samples
Following properties are automatically set:
vendorname
-> calculated from registration.phpmodulename
-> calculated from registration.phpCommentsCompanyName
commentsUserEmail
commentsYear
-
For all placehoders two versions with
Uppercase first
andlowercase
are created. That means, that for every praceholder there will be 2 created:-
vendorname = companyexample
-
Vendorname = Companyexample
-
modulename = examplemodule
-
Modulename = Examplemodule
-
customparam = somevalue
-
Customparam = Somevalue
-
-
Thanks to that, the user needs to enter only 1 value but 2 different placeholders can be used on the templates.