huttopia / console-bundle
Add some nice features to symfony/console
Installs: 62 116
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 5
Open Issues: 0
Requires
- php: >=7.1.2
- symfony/console: ^2.3|^3.0|^4.0|^5.0
- symfony/framework-bundle: ^2.3|^3.0|^4.0|^5.0
This package is auto-updated.
Last update: 2025-02-19 18:53:37 UTC
README
ConsoleBundle
Allow to exclude some commands.
For example, if you don't want to have doctrine:schema:update command in prod env: now you can :).
Add configuration to doctrine:schema:update to get queries for more than one database per connection.
Installation
composer require huttopia/console-bundle ^1.3
Replace parts of bin/console
:
# Replace use Symfony\Bundle\FrameworkBundle\Console\Application; by this one use Huttopia\ConsoleBundle\Application; # Add this line before $input = new ArgvInput(); $allCommands = \Huttopia\ConsoleBundle\CommandOption\AllCommandsOption::parseAllCommandsOption($argv); $input = new ArgvInput(); # Replace Application creation (it should be the last 2 lines of your bin/console) // $application = new Application($kernel); // $application->run($input); (new Application($kernel)) ->setAllCommands($allCommands) ->run($input);
Symfony <= 3
# app/AppKernel.php class AppKernel { public function registerBundles() { $bundles = [ new \Huttopia\ConsoleBundle\ConsoleBundle() ]; } }
Symfony >= 4
# config/bundles.php return [ Huttopia\ConsoleBundle\ConsoleBundle::class => ['all' => true] ];
Exclude commands
# Symfony <= 3: app/config/config.yml # Symfony >= 4: config/packages/console_bundle.yaml console: excluded: - 'foo:bar:baz' - 'bar:foo:baz'
Hide parts of command list
When you call bin/console
or bin/console list
, you see the list of commands.
Output is cut in 4 parts:
- Symfony version, environment and debug mode state
- Help for usage syntax
- Help for options available with all commands
- Commands list
You can configure at what verbosity level each part will be shown.
Verbosity level could be 0
, 1
(-v
), 2
(-vv
) or 3
(-vvv
).
# Symfony <= 3: app/config/config.yml # Symfony >= 4: config/packages/console_bundle.yaml console: list: symfonyVersionVerbosityLevel: 1 usageVerbosityLevel: 1 optionsVerbosityLevel: 1 availableCommandsVerbosityLevel: 0
Colorise some commands
When you call bin/console
or bin/console list
, you see the list of commands.
You can change the color of each part of the command name and description:
console:
list:
output:
# See https://symfony.com/doc/current/console/coloring.html
styles:
foo:
foreground: cyan # 1st parameter of new OutputFormatterStyle()
background: green # 2nd parameter of new OutputFormatterStyle()
options: [bold, underscore] # 3rd parameter of new OutputFormatterStyle()
commands:
generate:benchmark: "<foo>%%s</>%%s%%s" # 1st %s is command name, 2nd is spaces between name and description and 3rd is the description
highlights: # Shortcut for "<highlight>%%s</>%%s<highlight>%%s</>" who will write command name and description in cyan instead of green and white
- 'cache:clear'
doctrine:schema:update for more than one database
doctrine:schema:update has a major problem for us: only one database per connection is managed.
In our projects, we have more than one database per connection, so doctrine:schema:update don't show queries for all our databases.
UpdateDatabaseSchemaCommand replace doctrine:schema:update and call old doctrine:schema:update for all configured databases!
Configuration
# Symfony <= 3: app/config/config.yml # Symfony >= 4: config/packages/console_bundle.yaml console: databases: - database_name_1 - database_name_2