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
Copy file name to clipboardExpand all lines: README.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,6 +240,25 @@ The generate option allows you to control which generators get used for the spec
240
240
241
241
The list of generator names you can use are: `constructor,from-validated-array,to-array,getters,withers`
242
242
243
+
### Continuous Integration Setup
244
+
245
+
If you are committing your struct gen changes directly in the repo, then you'll want to make sure that struct-gen was properly run and tested before any commit is merged into the mainline branch.
246
+
247
+
In that case, you'll want to use the `--fail-on-changes` flag while running struct gen during your CI testing pipeline. This will fail with exit code 1 if any changes are detected which in most CI pipelines will fail the build ensuring that the developer submitting the patch has tested with the latest changes and didn't modify any of the generated files.
248
+
249
+
Example:
250
+
```yaml
251
+
- composer struct-gen:generate --fail-on-changes
252
+
```
253
+
254
+
If you are generating the structs into an external file via the `generatedPath` option and are ignoring that file in your CVS, then you'll want to make sure to run struct-gen **before you run composer install**.
255
+
256
+
```yaml
257
+
- composer struct-gen:generate -vv
258
+
# some point later
259
+
- composer install --no-dev -o
260
+
```
261
+
243
262
## Why use static generation?
244
263
245
264
Most libraries for DTOs or structs are not IDE friendly and give access to helpful methods for a struct via runtime magic and reflection. Not only is there a slight performance hit with these methods, it's difficult to get typesafe while also working well with ides and static analysis tools.
@@ -30,23 +30,27 @@ protected function configure() {
30
30
->setDescription('Generate struct info for any matching classes')
31
31
->addArgument('paths', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Path globs to search and list directories', $this->config->paths())
32
32
->addOption('generated-path', 'g', InputOption::VALUE_REQUIRED, 'If set, the file path to generate the structs into', $this->config->generatedPath())
33
+
->addOption('fail-on-changes', 'f', InputOption::VALUE_NONE, 'Ensures no changes are detected on generated structs by exiting with a failure if changes are detected.')
33
34
->addOption('basic-traverse-files', 'b', InputOption::VALUE_NONE, 'By default, this command will use symfony finder to traverse the list of paths which support glob patterns. If you do not want to include symfony finder, you can use the basic traverse files feature.');
0 commit comments