Skip to content

Commit e8cf06f

Browse files
authored
Merge pull request #7408 from sammyskills/docs-update-cli-generators
docs: add note for custom command generator template
2 parents 848c598 + abf3734 commit e8cf06f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

user_guide_src/source/cli/cli_generators.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,16 @@ GeneratorTrait
308308

309309
All generator commands must use the ``GeneratorTrait`` to fully utilize its methods that are used in code
310310
generation.
311+
312+
*************************************************************
313+
Declaring the Location of a Custom Generator Command Template
314+
*************************************************************
315+
316+
The default order of lookup for generator templates is (1) the template defined in the **app/Config/Generators.php** file,
317+
and (2) if not found, the template found at the ``CodeIgniter\Commands\Generators\Views`` namespace.
318+
319+
To declare the template location for your custom generator command, you will need to add it to the **app/Config/Generators.php**
320+
file. For example, if you have a command ``make:awesome-command`` and your generator template is located within your *app*
321+
directory **app/Commands/Generators/Views/awesomecommand.tpl.php**, you would update the config file like so:
322+
323+
.. literalinclude:: cli_generators/001.php
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Config;
4+
5+
use CodeIgniter\Config\BaseConfig;
6+
7+
class Generators extends BaseConfig
8+
{
9+
public array $views = [
10+
// ..
11+
'make:awesome-command' => 'App\Commands\Generators\Views\awesomecommand.tpl.php',
12+
];
13+
}

0 commit comments

Comments
 (0)