Open imam opened 7 years ago
Hi, funny I got hit by that just yesterday too :/
Here is what I did:
Application
class so that it can be autowired:
https://github.com/mnapoli/gitstats/blob/a731d6c9d91c8e4f07db0bec6e22c912a55baef2/src/Application.php#L21-L29getHelperSet()
: https://github.com/mnapoli/gitstats/blob/a731d6c9d91c8e4f07db0bec6e22c912a55baef2/src/TaskRunner.php#L81-L84I'd like to find a better solution too. Maybe the silly-php-di
package could preconfigure the Application
class? (I cannot inject the HelperSet using PHP-DI because it needs to be constructed using the Input and Output)
Another solution could be to use the SymfonyStyle
class and skip helpers altogether: https://symfony.com/doc/current/console/style.html
$io = new SymfonyStyle($input, $output);
$io->ask('What is your name?');
That's simpler, though a bit hidden in Symfony's documentation.
What kind of helpers are you using?
Currently, I can't use
getHelperSet()
method because I create a separate class that will be autowired by PHP-DI. So now, if I want to usegetHelperSet()
I have to use the old way to attach a command, by attaching a function to$app->command()
second argument rather than attaching my separated class. Is there any workaround for this situation?