2017 © Pedro Peláez
 

library console-bundle

Add some nice features to symfony/console

image

huttopia/console-bundle

Add some nice features to symfony/console

  • Monday, April 9, 2018
  • by huttopia
  • Repository
  • 3 Watchers
  • 1 Stars
  • 958 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 15 % Grown

The README.md

version symfony symfony LinesTotal Downloads, (*1)

ConsoleBundle

Allow to exclude some commands., (*2)

For example, if you don't want to have doctrine:schema:update command in prod env: now you can :)., (*3)

Add configuration to doctrine:schema:update to get queries for more than one database per connection., (*4)

Changelog, (*5)

Installation

composer require huttopia/console-bundle ^1.3

Replace parts of bin/console:, (*6)

# 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., (*7)

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, (*8)

You can configure at what verbosity level each part will be shown., (*9)

Verbosity level could be 0, 1 (-v), 2 (-vv) or 3 (-vvv)., (*10)

# 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., (*11)

You can change the color of each part of the command name and description:, (*12)

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., (*13)

In our projects, we have more than one database per connection, so doctrine:schema:update don't show queries for all our databases., (*14)

UpdateDatabaseSchemaCommand replace doctrine:schema:update and call old doctrine:schema:update for all configured databases!, (*15)

Configuration

# Symfony <= 3: app/config/config.yml
# Symfony >= 4: config/packages/console_bundle.yaml
console:
    databases:
        - database_name_1
        - database_name_2

The Versions

09/04 2018

4.0.8.x-dev

4.0.8.9999999-dev

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

  • php >=7.1.2

 

09/04 2018

dev-feature/967/symfony4

dev-feature/967/symfony4

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

  • php >=7.1.2

 

29/05 2017

dev-master

9999999-dev

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

 

29/05 2017

1.1.1

1.1.1.0

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

 

25/05 2017

dev-fix-title

dev-fix-title

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

 

06/05 2017

1.1.0

1.1.0.0

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires

 

05/05 2017

1.0.0

1.0.0.0

Add some nice features to symfony/console

  Sources   Download

MIT

The Requires