Developed with love by KnpLabs Hire us for your project!
40

ConsoleBundle

by RapotOR

Execute Symfony2 command directly from the application

Introduction

The Sf2gen namespace will be used for a future project. Sf2genConsoleBundle will be a little part of it.
Sf2genConsoleBundle give you the possibility to be able to execute a console command direclty from your application.
The interface is loaded with the same way than the WebProfilerBundle.

Features

  • Command autocompletion
  • Command history

Use it

Instead of typing php app/console list, you will just have to type list.
The dot is an alias for list.

Have a look :

Installation

  1. Add this bundle to your vendor/ dir:

    $ git submodule add git://github.com/RapotOR/ConsoleBundle.git vendor/bundles/Sf2gen/Bundle/ConsoleBundle
    
  2. Add the Sf2gen namespace to your autoloader:

    // app/autoload.php
    $loader->registerNamespaces(array(
        'Sf2gen' => __DIR__.'/../vendor/bundles',
        // other namespaces
    ));
    
  3. Add this bundle to your application's kernel, in the debug section:

    // app/ApplicationKernel.php
    public function registerBundles()
    {
        $bundles = array(
            // all bundles
        );
    
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // previous bundles like WebProfilerBundle
            $bundles[] = new Sf2gen\Bundle\ConsoleBundle\Sf2genConsoleBundle();
        }
    
        return $bundles;
    }
    
  4. Add the following ressource to your routing_dev.yml:

    // app/config/routing_dev.yml
    _sf2gencdt:
        resource: "@Sf2genConsoleBundle/Resources/config/routing.yml"
        prefix:   /_sf2gencdt
    
  5. You have to disable the firewall if you use the security component:

    # app/config/config.yml
    security:
        firewalls:
            sf2gen:
                pattern:    /_sf2gencdt/.*
                security:  false
    
  6. Here is the full configuration:

    # app/config/config.yml
    sf2gen_console:
        new_process: true  # use a new shell process to launch the command
        toolbar: true  # display the toolbar in the current application ; to be disabled to use it in a third application.
        local: true   # add the current application to list of available apps ; if false, the current application is excluded.
        all: false   # will add all apps with a console available without using `apps` in configuration.
        env: %kernel.environment% #the env used for the kernel setup
        apps: #  use this to have a well defined list.
            - app
            - symfony-standard
    
sf2gen_console:
new_process: false
toolbar: true
all: false
local: true
env: %kernel.environment%
apps: []
  • Merge pull request #30 from Fran6co/patch-1
    By RapotOR, 5 years ago
  • Symfony 2.1 compatibility
    By Fran6co, 5 years ago
  • Update composer with Symfony v2.1
    By RapotOR, 5 years ago
  • Merge pull request #26 from jfsimon/issue-24
    By RapotOR, 5 years ago
  • Merge pull request #27 from stof/composer
    By RapotOR, 5 years ago
  • Added a composer.json file
    By stof, 5 years ago
  • Fix for Symfony 2.1
    By jfsimon, 5 years ago
  • Merge pull request #22 from catacgc/master
    By RapotOR, 5 years ago
  • update docs
    By catacgc, 5 years ago
  • add a env parameter to bundle configuration and use by default the %kernel.environment% param
    By catacgc, 5 years ago
  • Merge pull request #20 from stof/input
    By RapotOR, 5 years ago
  • Fixed the input parsing by using StringInput
    By stof, 5 years ago
  • Merge pull request #18 from stof/cleanup
    By RapotOR, 5 years ago
  • Cleaned the way the listener finds the command name
    By stof, 5 years ago
  • Removed useless file
    By stof, 5 years ago
  • Removed unused properties
    By stof, 5 years ago
  • Fixed a method name and remove a useless call
    By stof, 5 years ago
  • Cleaned the way the command is called to keep the code DRY
    By stof, 5 years ago
  • Fixed CS following the Symfony2 ones
    By stof, 5 years ago
  • Removed useless methods
    By stof, 5 years ago
  • Merge pull request #17 from stof/css
    By RapotOR, 5 years ago
  • Updated the cSS to fix the conflict with SonataAdminBundle
    By stof, 5 years ago
  • set new_process:false by default
    By RapotOR, 6 years ago
  • Fix cache:clear issue (issue #11)
    By RapotOR, 6 years ago
  • Merge pull request #14 from nicodmf/master
    By RapotOR, 6 years ago
  • Rewrite formatting to colorize stream
    By nicodmf, 6 years ago
  • Change outpout stream from file to php://out
    By nicodmf, 6 years ago
  • Typo : Change config.php to config.yml
    By nicodmf, 6 years ago
  • Update to beta for listener - Remove bug for cache dir permissions
    By nicodmf, 6 years ago
  • Fix new process issue. Errors were not thrown when executable was not found. also, Executable test validity fixed (issue #13)
    By RapotOR, 6 years ago