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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add standard Symfony commands #1117
Conversation
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 don't know if silly supports autocompletion, but this is a feature that we can provide to bref by using the standard Symfony Console v5.4+.
demo/console.php
Outdated
}); | ||
$silly->command('sleep', function () { | ||
sleep(120); | ||
$app->add(new class('hello') extends Command { |
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.
The register
method should be used for this case.
$app->register('hello')
->addArgument('name', InputArgument::OPTIONAL, '', 'World!')
->setCode(function (InputInterface $input, OutputInterface $output): int {
$output->writeln('Hello, ' . $input->getArgument('name'));
return Command::SUCCESS;
});
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.
Way better, thanks!
Ohh tests on master fail, probably because https://github.com/shivammathur/setup-php changed the way PHP-FPM installs again. I think we need to revert some parts of #991 I can't address this right now (I have a live stream tonight), maybe tomorrow if someone else doesn't get to this first. |
@@ -22,7 +22,7 @@ | |||
"php": ">=7.3.0", | |||
"ext-curl": "*", | |||
"ext-json": "*", | |||
"mnapoli/silly": "^1.7", | |||
"symfony/console": "^3.0|^4.0|^5.0|^6.0", |
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.
Is it necessary to support old and unmaintained versions? ^4.4|^5.0|^6.0
should be enough.
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 just copied the requirement from Silly, and then added ^6.0
. I'd suggest to keep support for the old releases for now, and to think about it together with the other Symfony requirements in another issue/PR.
src/Console/Command/Local.php
Outdated
{ | ||
protected static $defaultName = 'local'; | ||
|
||
public const SIGNATURE = 'local [function] [data] [--file=] [--handler=] [--config=]'; |
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.
This const is not used.
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.
Strictly speaking this is a BC break but should be ok anyway.
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.
Removing __invoke
from this class is a more risked breaking change. I don't know what's the policy here.
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.
Fair enough :-) I didn't find statements on BC in the docs, so am unsure, too.
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.
Feel free to remove, no BC break guarantee for console commands.
@mnapoli Sorry 馃憖 I tested the The requirement on symfony/console 3.x breaks the tests on |
AFAIK defining the static property is only useful when you want to be able to lazy-load commands if using the Symfony framework (see https://symfony.com/doc/current/console/commands_as_services.html#lazy-loading) I think it's OK to switch to the "old-school way" as Symfony 3 is not a huge obstacle here apparently. |
Let's give this a try, thank you @umulmrum! |
This PR replaces Silly commands with default Symfony commands. As both Bref and Silly are maintained by @mnapoli, they might not be amused, so let me explain my thoughts:
Silly indeed removes some boilerplate code required by Symfony, turning command definitions significantly easier. So there is definitely benefit in using it, but I think it doesn't justify the related cost.
As a final point, I'd say that the new command classes in this PR make it easier to write tests for the commands (and I think separate classes are way easier to understand, but this might be a matter of opinion), but this could also be reached by simple refactoring.
All that said, I'm relatively new to Bref and might have overlooked significant things. Also, the changes are mostly untested yet and I'm sure that arguments/options aren't correct yet. I'm happy to complete the PR if you are 馃憤 in general. Thanks!