symfony-bundle console-bundle
Execute Symfony2 command directly from the application
rapotor/console-bundle
Execute Symfony2 command directly from the application
- Saturday, September 22, 2012
- by rapotor
- Repository
- 2 Watchers
- 28 Stars
- 73 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 6 Forks
- 9 Open issues
- 2 Versions
- 0 % Grown
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., (*1)
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., (*2)
Have a look :, (*3)
, (*4)
Installation
-
Add this bundle to your vendor/ dir:, (*5)
$ git submodule add git://github.com/RapotOR/ConsoleBundle.git vendor/bundles/Sf2gen/Bundle/ConsoleBundle
-
Add the Sf2gen namespace to your autoloader:, (*6)
// app/autoload.php
$loader->registerNamespaces(array(
'Sf2gen' => __DIR__.'/../vendor/bundles',
// other namespaces
));
-
Add this bundle to your application's kernel, in the debug section:, (*7)
// 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;
}
-
Add the following ressource to your routing_dev.yml:, (*8)
// app/config/routing_dev.yml
_sf2gencdt:
resource: "@Sf2genConsoleBundle/Resources/config/routing.yml"
prefix: /_sf2gencdt
-
You have to disable the firewall if you use the security component
:, (*9)
# app/config/config.yml
security:
firewalls:
sf2gen:
pattern: /_sf2gencdt/.*
security: false
-
Here is the full configuration:, (*10)
# 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