Commander icon indicating copy to clipboard operation
Commander copied to clipboard

Using CommanderTrait with Console commands

Open kellytehuna opened this issue 10 years ago • 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

kellytehuna avatar May 11 '15 20:05 kellytehuna