laracasts / Commander

Easily leverage commands and domain events in your Laravel projects.
https://laracasts.com/series/commands-and-domain-events
MIT License
279 stars 68 forks source link

Using CommanderTrait with Console commands #61

Open kellytehuna opened 9 years ago

kellytehuna commented 9 years ago

I recently hit a snag with using the CommanderTrait with a class inheriting from Illuminate/Console/Command. Because CommandTrait declares its own execute() method, there is a signature conflict with the method declared in Illuminate/Console/Command.

The solution I came up with was to create a class, CommanderExecutor, that uses the CommanderTrait and inject an instance of that CommanderExecutor as a class dependency, then referenced the object to invoke execute(). It's a little bit hacky, but it works