-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Framework] allow to create kernel-aware console applications without default commands #21019
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
[Framework] allow to create kernel-aware console applications without default commands #21019
Conversation
… default commands
@ro0NL here |
You could have changed the base branch on your previous PR as well ;-) You should add a test if this is accepted 👍 |
This should make it easier to create single command applications I believe? |
@iltar yes, in particular kernel-aware ones |
Thanks all for reviewing this. Now about the doc part, is there already a page which explains how to create kernel-aware console applications? Afaik the only place where |
Maybe a special note at https://symfony.com/doc/current/components/console/single_command_tool.html? Howto create a single command app with the framework something like that? |
@ro0NL I don't think so, because it hasn't to be necessarily one single command. It can be even with multiple commands. Maybe it's better to create a new dedicated page about "How to create a kernel-aware console application" ? |
It's about creating awareness of this small feature. I think the single command tool page has the most visits by now, and is best indexed. Besides, this definitely relates to creating a truly single command tool with the framework ;-) If we explain it right there, people will probably understand this is applies to multiple commands as well. |
PR for the doc done: |
any news? |
*/ | ||
public function __construct(KernelInterface $kernel) | ||
public function __construct(KernelInterface $kernel, $loadDefaultCommands = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name it registerDefaultCommands
to be consistent.
Moving to 4.1. Rebase on master needed, where PHP 7.1 features can be used btw. |
@FrancescoBorzi can you please rebase this PR? |
I opened this PR on I no longer use Symfony for a while and to be honest I don't even remember what I did here. Sorry. |
Suppose that you need to create a kernel-aware application:
The code above will create a console application with
MyCustomCommand
plus all the other default symfony commands.With this PR you are able to specify whether or not you want to add the default commands:
$application = new MyApplication($kernel, false);
or
$application = new MyApplication($kernel, true);
(default)