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
+79-20Lines changed: 79 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ composer require cerbero/enum
39
39
*[🦾 Console commands](#-console-commands)
40
40
*[🗒️ annotate](#%EF%B8%8F-annotate)
41
41
*[🏗️ make](#%EF%B8%8F-make)
42
+
*[💙 ts](#%EF%B8%8F-ts)
42
43
43
44
To supercharge our enums with all the features provided by this package, we can let our enums use the `Enumerates` trait:
44
45
@@ -406,6 +407,24 @@ This package provides a handy binary, built to automate different tasks. To lear
406
407
./vendor/bin/enum
407
408
```
408
409
410
+
For the console commands to work properly, the application base path is automatically guessed. However, in case of issues, we can manually set it by creating an `enums.php` file in the root of our app:
411
+
412
+
```php
413
+
<?php
414
+
415
+
use Cerbero\Enum\Enums;
416
+
417
+
Enums::setBasePath(__DIR__);
418
+
```
419
+
420
+
Some commands support the option `--all` to reference all the enums of our application. We can set the paths where enums live in our app in the `enums.php` configuration file as well:
421
+
422
+
```php
423
+
Enums::setPaths('app/Enums', 'domain/*/Enums');
424
+
```
425
+
426
+
In the above example, enums are discovered in the `app/Enums` directory and in all `Enums` sub-folders belonging to `domain`, e.g. `domain/Posts/Enums`, `domain/Users/Enums`, etc.
427
+
409
428
#### 🗒️ annotate
410
429
411
430
The `annotate` command automatically adds method annotations to enums, making IDEs autocompletion possible:
@@ -432,28 +451,12 @@ Otherwise we can annotate all our enums at once by enabling the option `--all`:
432
451
./vendor/bin/enum annotate -a
433
452
```
434
453
435
-
For the option `--all` to work, we need to set the paths where enums live in our application:
436
-
437
-
```php
438
-
use Cerbero\Enum\Enums;
439
-
440
-
Enums::setPaths('app/Enums', 'domain/*/Enums');
441
-
```
442
-
443
-
In the above example, enums are discovered in the `app/Enums` directory and in all `Enums` sub-folders belonging to `domain`, e.g. `domain/Posts/Enums`, `domain/Users/Enums`, etc.
444
-
445
-
This package tries to automatically find the application base path. However if enums can't be discovered after setting their paths, we can manually set our application base path:
446
-
447
-
```php
448
-
Enums::setBasePath(__DIR__ . '/path/to/our/app');
449
-
```
450
-
451
454
If we want to overwrite method annotations already annotated on enums, we can add the option `--force`:
This package tries to automatically find the application base path. However if enums can't be successfully created, we can manually set our application base path:
503
+
Finally, we can generate the TypeScript counterpart of the newly created enum by adding the `--typescript` option:
0 commit comments