Comments (13)
@enumag Thanks. We might support it. Good point. I'll implement it.
Any other thoughts/ideas? Please consider it as small as possible. ;-)
from console.
@enumag HelperSet is just another services locator. I'm strictly against it, because it leads you to write overcomplicated structures as in Kdyby.
What is the advantage over constructor injection?
from console.
@TomasVotruba Symfony commands are not really compatible with constructor injection because all of them are instantiated every time you use console - instead of only the one you need. If you know a solution, please share.
from console.
@enumag Why is that issue? I use is for years like that and never had a problem.
If so, it belongs to Symfony\Console repository, not anywhere else.
Do you prefer service locators then?
from console.
@TomasVotruba It is a problem because I don't want to create all the services any command might have a dependency on every time I run any of them. Sometimes I use commands as long-running processes and I want to reduce their memory usage - meaning it's better to instantiate only what is necessary for the given command. This is the same thing as with Presenters/Controllers - would you want to instantiate all of them for every http request? Me neither. But this of course means there is some sort of service locator in PresenterFactory/ControllerResolver - and that's ok with me.
The thing with service locator is that it is not necessarily bad nor fully replaceable by dependency injection. It just should be used carefully and mainly hidden in libraries, but not used in applications themselves. This is of course why you dislike console helper. And I agree with you, I don't like them either. The service locator would be far better to have in Symfony\Component\Console\Application
to load commands, not in the commands themselves. The real issue here is that Symfony\Component\Console\Command\Command::configure()
is not static and implement this would require hacks involving ReflectionClass::newInstanceWithoutConstructor()
.
from console.
@enumag Still, Symfony\Console issue. This is wrong level of abstraction to workaround this.
There are many similar issues:
https://github.com/symfony/symfony/issues?utf8=%E2%9C%93&q=resolve%20is%3Aopen%20label%3AConsole%20
I recommend you focusing your energy there. It might actually change something and make situation better for all Symfony\Console integrations.
from console.
@TomasVotruba Precisly. But since there is no better solution at the moment it is still needed.
I'm well aware of those issues but since they have been sitting there for years I consider it a waste of time. Solving it is too much of a BC break for Symfony.
from console.
@enumag I've discovered that some default helpers are already setup in Symfony\Application
(https://github.com/symfony/console/blob/v3.2.8/Application.php#L84).
I've merged #4 just few minutes ago. Do you need anything more? I saw some Container and Presenter helpers in Kdyby. Do you need them too?
from console.
I think #4 is enough. Please don't pollute this package with Kdyby garbage.
from console.
@enumag Great. But, what about ContainerHelper or PresenterHelper, do you use them? In case of you do, do you want to create them for each project?
from console.
ContainerHelper is about the only way to use services in commands. Or do you know any other? PresenterHelper - no thanks.
from console.
@enumag Could we consider this issue as done?
I experiment with some ProxyCommands for lazy-loading. We'll see. :-)
from console.
Yeah, thanks!
from console.
Related Issues (20)
- Bump PHP 7.1
- Entrypoint - Špatná detekce wwwDir HOT 4
- Provide CLI mode, e.q. Contributte\Console\DI\ConsoleExtension(%consoleMode%). HOT 1
- Autoconfigure event dispatcher if available
- Nette 3.0 compatiblity issue
- Lazy mode, BC break? HOT 1
- Basic commands [idea] HOT 7
- The option 'console › version' expects to be string, float given. HOT 1
- PHP 7.3 support HOT 1
- Allow nullable url
- There is not any default HelperSet? HOT 4
- Not able to build without helperSet HOT 3
- Any ETA on stable version supporting PHP 8? HOT 1
- Lazy commands and callInjects HOT 13
- Packages and PHP requirements update HOT 2
- Get rid of foo in sake of newbies HOT 4
- ConsoleExtension doesn't support `Nette\DI\Statement` HOT 1
- Lazy-loading of command dependencies HOT 15
- Compatibility with contributte/di 0.6.* HOT 2
- Support for nette 3.1 and nette/utils 4.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console.