Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get helper from classes autowired by PHP-DI #42

Open
imam opened this issue Oct 24, 2017 · 1 comment
Open

Get helper from classes autowired by PHP-DI #42

imam opened this issue Oct 24, 2017 · 1 comment

Comments

@imam
Copy link

imam commented Oct 24, 2017

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 use getHelperSet() 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?

@mnapoli
Copy link
Owner

mnapoli commented Oct 24, 2017

Hi, funny I got hit by that just yesterday too :/

Here is what I did:

I'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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants