Skip to content

Commit 1b38b2a

Browse files
committed
ICL: Troubleshooting section - new examples added.
1 parent ea12aef commit 1b38b2a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Provides logging and email notifications for Laravel console commands.
3535

3636
## Troubleshooting
3737

38+
#### Trait included, but nothing happens?
39+
3840
Note, that `Loggable` trait is overriding `initialize` method:
3941
```php
4042
trait Loggable
@@ -65,3 +67,37 @@ class Foo extends Command
6567
// ...
6668
}
6769
```
70+
71+
#### Several traits conflict?
72+
73+
If you're using some other cool `illuminated/console-%` packages, well, then you can find yourself getting "traits conflict".
74+
For example, if you're trying to build loggable command, which is [protected against overlapping](https://packagist.org/packages/illuminated/console-mutex):
75+
```php
76+
class Foo extends Command
77+
{
78+
use Loggable;
79+
use WithoutOverlapping;
80+
81+
// ...
82+
}
83+
```
84+
85+
You'll get fatal error, the "traits conflict", because both of these traits are overriding `initialize` method:
86+
>If two traits insert a method with the same name, a fatal error is produced, if the conflict is not explicitly resolved.
87+
88+
But don't worry, solution is very simple. Just override `initialize` method by yourself, and initialize traits in required order:
89+
```php
90+
class Foo extends Command
91+
{
92+
use Loggable;
93+
use WithoutOverlapping;
94+
95+
protected function initialize(InputInterface $input, OutputInterface $output)
96+
{
97+
$this->initializeMutex();
98+
$this->initializeLogging();
99+
}
100+
101+
// ...
102+
}
103+
```

0 commit comments

Comments
 (0)