https://github.com/huttopia/console-bundle
Add some nice features to symfony/console
https://github.com/huttopia/console-bundle
console doctrine2 php php7 php71 symfony symfony-console
Last synced: 10 months ago
JSON representation
Add some nice features to symfony/console
- Host: GitHub
- URL: https://github.com/huttopia/console-bundle
- Owner: Huttopia
- Created: 2017-05-05T12:40:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-09-19T13:42:42.000Z (over 3 years ago)
- Last Synced: 2025-04-09T20:04:11.523Z (10 months ago)
- Topics: console, doctrine2, php, php7, php71, symfony, symfony-console
- Language: PHP
- Size: 25.4 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
[](https://github.com/huttopia/console-bundle)
[](https://symfony.com)
[](https://symfony.com)


# 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.
[Changelog](changelog.md)
# Installation
```bash
composer require huttopia/console-bundle ^1.3
```
Replace parts of `bin/console`:
```php
# 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
```php
# app/AppKernel.php
class AppKernel
{
public function registerBundles()
{
$bundles = [
new \Huttopia\ConsoleBundle\ConsoleBundle()
];
}
}
```
## Symfony >= 4
```yaml
# config/bundles.php
return [
Huttopia\ConsoleBundle\ConsoleBundle::class => ['all' => true]
];
```
# Exclude commands
```yaml
# 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`).
```yaml
# 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: "%%s>%%s%%s" # 1st %s is command name, 2nd is spaces between name and description and 3rd is the description
highlights: # Shortcut for "%%s>%%s%%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
```yaml
# Symfony <= 3: app/config/config.yml
# Symfony >= 4: config/packages/console_bundle.yaml
console:
databases:
- database_name_1
- database_name_2
```