Skip to content

Commit 84d206a

Browse files
committed
added explanation for custom command generator templates
1 parent 354dc67 commit 84d206a

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

user_guide_src/source/cli/cli_generators.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,14 @@ 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+
Accessing a Custom Generator Template
314+
*************************************
315+
316+
By default, all generator templates will be looked up at the ``CodeIgniter\Commands\Generators\Views`` namespace.
317+
To declare a custom location for your custom generator template, you will need to add it to the ``app/Config/Generators.php``
318+
file. For example, if you have a command ``make:awesome-command`` and your generator template is located within your *app*
319+
directory ``app/Commands/Generators/Views/awesomecommand.tpl.php``, you would update the config file like so:
320+
321+
.. 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\awesomecommand.tpl.php',
12+
];
13+
}

0 commit comments

Comments
 (0)