New in Symfony 7.1: Commands Improvements
Symfony includes many commands to perform common operations in your applications.
In Symfony 7.1, we are improving some commands with new options and features.
New Command to Reveal Secrets
Contributed by
Daniel Burger
in #53466.
Symfony provides a feature to manage secrets that encrypts and stores the
given values in a secure vault. When developing applications, it might be
useful to see the original plain text value of a secret. That’s why in
Symfony 7.1 we’ve introduced a new secrets:reveal command:
# the command outputs the plain text value of the database password
# (e.g. you can pipe this output to another command)
$ php bin/console secrets:reveal DATABASE_PASSWORD
Improved the debug:serializer Command
Contributed by
Jan Schädlich
in #52730.
The debug:serializer command helps you find issues when using the
Serializer component. In Symfony 7.1 we’ve improved it to also display the
serialized path:
$ php bin/console debug:serializer ‚AppEntityBook‘
AppEntityBook
—————
+———-+————————————————————+
| Property | Options |
+———-+————————————————————+
| name | … |
| isbn | |
| | … |
| | „serializedName“ => null, |
| | „serializedPath“ => [data][isbn], |
| … | … |
+———-+————————————————————+
Improved messenger:consume Command
Contributed by
javaDeveloperKid
in #52411.
When consuming messages of the Messenger component, you run the messenger:consume
command and pass the name of the receiver or service:
$ php bin/console messenger:consume async
In Symfony 7.1, we’re adding a new –all option so you can consume messages
from all the available receivers:
$ php bin/console messenger:consume –all
Improved twig:lint Command
Contributed by
Antoine M.
in #50864.
The lint:twig command checks that your Twig templates don’t have any syntax
errors. It’s useful to run it before deploying your application to production
(e.g. in your continuous integration server).
If you have some special Twig templates (e.g. related to some data collector)
you may get false positives when linting them. That’s why in Symfony 7.1 we’re
adding a –excludes option so you can ignore certain directories:
$ php bin/console lint:twig templates/ –excludes=data_collector/ –excludes=some_dev_tool/
Getting all Command Tokens
Contributed by
Grégoire Pineau
in #54347.
In Symfony 7.1 we also added a getRawTokens() method to the
ArgvInput. This method allows to
fetch the raw input that was passed to the command, including all options and
arguments. This is useful to parse the input yourself or to pass the entire input
to another command.
For example, if you run this command:
$ php bin/console app:my-command foo –bar –baz=3 –qux=value1 –qux=value2
This would be the output of the new method:
$tokens = $input->getRawTokens();
// $tokens = [‚app:my-command‘, ‚foo‘, ‚–bar‘, ‚–baz=3‘, ‚–qux=value1‘, ‚–qux=value2‘];
// pass true as argument to not include the original command name
$tokens = $input->getRawTokens(true);
// $tokens = [‚foo‘, ‚–bar‘, ‚–baz=3‘, ‚–qux=value1‘, ‚–qux=value2‘];
// pass the raw input to any other command (from Symfony or the operating system)
$process = new Process([‚app:other-command‘, …$input->getRawTokens(true)]);
Symfony Blog