laracasts/Commander

Using CommanderTrait with Console commands

Opened this issue · 0 comments

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