You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 07e3f33
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/changelogs/v4.3.0.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -250,7 +250,7 @@ The following items are affected:
250
250
-**Config:** Now you can specify Composer packages to auto-discover manually. See [Code Modules](../general/modules.md#specify-composer-packages).
251
251
-**Config:** Added `Config\Session` class to handle session configuration.
252
252
-**Debug:** Kint has been updated to 5.0.2.
253
-
-**Request:** Added new `$request->getRawInputVar()` method to return a specified variable from the raw stream. See [Retrieving Raw data](../incoming/incomingrequest.md#retrieving-raw-data-put-patch-delete).
253
+
-**Request:** Added new `$request->getRawInputVar()` method to return a specified variable from the raw stream. See [Retrieving Raw data](../incoming/incomingrequest.md#retrieving-raw-data-put-patch-delete-query).
254
254
-**Request:** Added new `$request->is()` method to query the request type. See [Determining Request Type](../incoming/incomingrequest.md#is).
Copy file name to clipboardExpand all lines: docs/cli/cli_commands.md
+4-12Lines changed: 4 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,9 @@
2
2
3
3
While the ability to use Controllers via CLI like any other route is convenient, you might find times where you need a little something different. That's where Spark commands come in. They are simple classes that do not need to have routes defined, making them perfect for building tools that developers can use to make their jobs simpler, whether by handling migrations or database seeding, checking cronjob status, or even building out custom code generators for your company.
4
4
5
+
!!! danger "Deprecated since version 4.8.0"
6
+
`BaseCommand` is deprecated, and running a command that extends it triggers a deprecation notice. Write new commands against `AbstractCommand` instead. See [Modern Spark Commands](cli_modern_commands.md).
7
+
5
8
## Creating New Commands
6
9
7
10
You can very easily create new commands to use in your own development. Each class must be in its own file, must extend `CodeIgniter\CLI\BaseCommand`, and must implement the `run()` method.
Copy file name to clipboardExpand all lines: docs/cli/cli_generators.md
+81-46Lines changed: 81 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,14 @@ All built-in generators reside under the `Generators` group when listed using `p
8
8
9
9
```console
10
10
php spark help <generator_command>
11
+
php spark <generator_command> --help
11
12
```
12
13
13
14
where `<generator_command>` will be replaced with the command to check.
14
15
16
+
!!! note "Note"
17
+
The single-letter option shortcuts listed below (`-n`, `-s`, `-f`) are available since v4.8.0.
18
+
15
19
!!! note "Note"
16
20
Do you need to have the generated code in a subfolder? If you want to create a controller class to reside in the `Admin` subfolder of the main `Controllers` folder, you will just need to prepend the subfolder to the class name, like this: `php spark make:controller admin/login`. This command will create the `Login` controller in the `Controllers/Admin` subfolder with a namespace of `App\Controllers\Admin`.
17
21
@@ -43,8 +47,8 @@ make:cell <name> [options]
43
47
44
48
#### Options:
45
49
46
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
47
-
-`--force`: Set this flag to overwrite existing files on destination.
50
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
51
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
48
52
49
53
### make:command
50
54
@@ -62,12 +66,15 @@ make:command <name> [options]
62
66
63
67
#### Options:
64
68
65
-
-`--command`: The command name to run in spark. Defaults to `command:name`.
66
-
-`--group`: The group/namespace of the command. Defaults to `App` for basic commands, and `Generators` for generator commands.
67
-
-`--type`: The type of command, whether a `basic` command or a `generator` command. Defaults to `basic`.
68
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
69
-
-`--suffix`: Append the component suffix to the generated class name.
70
-
-`--force`: Set this flag to overwrite existing files on destination.
69
+
-`--command` (`-c`): The command name to run in spark. Defaults to `command:name`.
70
+
-`--type` (`-t`): The type of command, whether a `basic` command or a `generator` command. Defaults to `basic`.
71
+
-`--group` (`-g`): The group of the command. Defaults to `App` for basic commands, and `Generators` for generator commands.
72
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
73
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
74
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
75
+
76
+
!!! note "Note"
77
+
Since v4.8.0, the generated class is a [modern command](cli_modern_commands.md): a `basic` command extends `AbstractCommand`, and a `generator` command extends [AbstractGeneratorCommand](cli_modern_generators.md).
71
78
72
79
### make:config
73
80
@@ -85,9 +92,9 @@ make:config <name> [options]
85
92
86
93
#### Options:
87
94
88
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
89
-
-`--suffix`: Append the component suffix to the generated class name.
90
-
-`--force`: Set this flag to overwrite existing files on destination.
95
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
96
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
97
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
-`--bare`: Extends from `CodeIgniter\Controller` instead of `BaseController`.
109
-
-`--restful`: Extends from a RESTful resource. Choices are `controller` and `presenter`. Defaults to `controller`.
110
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
111
-
-`--suffix`: Append the component suffix to the generated class name.
112
-
-`--force`: Set this flag to overwrite existing files on destination.
115
+
-`--bare` (`-b`): Extends from `CodeIgniter\Controller` instead of `BaseController`.
116
+
-`--restful` (`-r`): Extends from a RESTful resource. Choices are `controller` and `presenter`. Defaults to `controller`.
117
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
118
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
119
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
113
120
114
121
!!! note "Note"
115
122
If you use `--suffix`, the generated controller name will be like `ProductController`. That violates the Controller naming convention when using [Auto Routing](../incoming/controllers.md#auto-routing-improved) (Controller class names MUST start with an uppercase letter and ONLY the first character can be uppercase). So `--suffix` can be used when you use [Defined Routes](../incoming/routing.md#setting-routing-rules).
@@ -130,9 +137,9 @@ make:entity <name> [options]
130
137
131
138
#### Options:
132
139
133
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
134
-
-`--suffix`: Append the component suffix to the generated class name.
135
-
-`--force`: Set this flag to overwrite existing files on destination.
140
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
141
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
142
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
136
143
137
144
### make:filter
138
145
@@ -150,9 +157,9 @@ make:filter <name> [options]
150
157
151
158
#### Options:
152
159
153
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
154
-
-`--suffix`: Append the component suffix to the generated class name.
155
-
-`--force`: Set this flag to overwrite existing files on destination.
160
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
161
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
162
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
156
163
157
164
### make:model
158
165
@@ -170,12 +177,32 @@ make:model <name> [options]
170
177
171
178
#### Options:
172
179
173
-
-`--dbgroup`: Database group to use. Defaults to `default`.
174
-
-`--return`: Set the return type from `array`, `object`, or `entity`. Defaults to `array`.
175
-
-`--table`: Supply a different table name. Defaults to the pluralized class name.
176
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
177
-
-`--suffix`: Append the component suffix to the generated class name.
178
-
-`--force`: Set this flag to overwrite existing files on destination.
180
+
-`--table` (`-t`): Supply a different table name. Defaults to the pluralized class name.
181
+
-`--dbgroup` (`-g`): Database group to use. Defaults to `default`.
182
+
-`--return` (`-r`): Set the return type from `array`, `object`, or `entity`. Defaults to `array`.
183
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
184
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
185
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
186
+
187
+
### make:request
188
+
189
+
Creates a new FormRequest file.
190
+
191
+
#### Usage:
192
+
193
+
```
194
+
make:request <name> [options]
195
+
```
196
+
197
+
#### Argument:
198
+
199
+
-`name`: The name of the FormRequest class. **[REQUIRED]**
200
+
201
+
#### Options:
202
+
203
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
204
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
205
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
179
206
180
207
### make:seeder
181
208
@@ -193,9 +220,9 @@ make:seeder <name> [options]
193
220
194
221
#### Options:
195
222
196
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
197
-
-`--suffix`: Append the component suffix to the generated class name.
198
-
-`--force`: Set this flag to overwrite existing files on destination.
223
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
224
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
225
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
199
226
200
227
### make:test
201
228
@@ -215,8 +242,8 @@ make:test <name> [options]
215
242
216
243
#### Options:
217
244
218
-
-`--namespace`: Set the root namespace. Defaults to `Tests`.
219
-
-`--force`: Set this flag to overwrite existing files on destination.
245
+
-`--namespace` (`-n`): Set the root namespace. Defaults to `Tests`.
246
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
-`--session`: Generate a migration file for database sessions.
258
-
-`--table`: Set the table name to use for database sessions. Defaults to `ci_sessions`.
259
-
-`--dbgroup`: Set the database group for database sessions. Defaults to `default` group.
260
-
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
261
-
-`--suffix`: Append the component suffix to the generated class name.
262
-
-`--force`: Set this flag to overwrite existing files on destination.
284
+
-`--session`: Generate a migration file for database sessions. The `name` argument is ignored.
285
+
-`--table` (`-t`): Set the table name to use for database sessions. Defaults to `ci_sessions`.
286
+
-`--dbgroup` (`-g`): Set the database group for database sessions. Defaults to `default` group.
287
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
288
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
289
+
290
+
!!! note "Note"
291
+
`make:migration` has no `--force` option, since the timestamped file name only collides with an existing file when the same name is generated twice within one second.
-`--namespace`: Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
281
-
-`--suffix`: Append the component suffix to the generated class name.
282
-
-`--force`: Set this flag to overwrite existing files on destination.
309
+
-`--namespace` (`-n`): Set the root namespace. Defaults to the value of `APP_NAMESPACE`.
310
+
-`--suffix` (`-s`): Append the component suffix to the generated class name.
311
+
-`--force` (`-f`): Set this flag to overwrite existing files on destination.
283
312
284
313
## Scaffolding a Complete Set of Stock Code
285
314
@@ -302,9 +331,15 @@ will create the following files:
302
331
303
332
To include an `Entity` class in the scaffolded files, just add `--return entity` to the command and it will be passed to the model generator.
304
333
334
+
!!! note "Note"
335
+
Since v4.8.0, `make:scaffold` accepts the `-b`, `-t`, `-g`, `-n`, `-s`, and `-f` shortcuts. `--restful` and `--return` have no shortcut here, since both use `-r` in their own commands. When the class name is omitted on an interactive run, it is asked for once and reused for every generated file.
336
+
305
337
## GeneratorTrait
306
338
307
-
All generator commands must use the `GeneratorTrait` to fully utilize its methods that are used in code generation.
339
+
!!! danger "Deprecated since version 4.8.0"
340
+
`GeneratorTrait` is the legacy way of building generator commands, tied to the deprecated `BaseCommand`. New generator commands should extend `AbstractGeneratorCommand` instead. See [Modern Generator Commands](cli_modern_generators.md).
341
+
342
+
Legacy generator commands use the `GeneratorTrait` to fully utilize its methods that are used in code generation.
308
343
309
344
## Declaring the Location of a Custom Generator Command Template
0 commit comments