There is no license information available for the latest version (v2.0.0) of this package.

Bundle that adds some flavor to Symfony2's commands

v2.0.0 2016-01-26 11:30 UTC


This bundle adds some sugar to the default ContainerAwareCommand. It provides methods to make your command single-processed, turn off logging, and more.


Installation for Symfony 3.0 (and up):

Require the dependency through Composer:

composer.phar require pk/command-extra-bundle

Register bundle:

// app/AppKernel.php
public function registerBundles()
    $bundles = array(
        // ...
        new PK\CommandExtraBundle\PKCommandExtraBundle(),
    // ...


The bundle mainly provides a class that you can extend your commands with. It's located at PK\CommandExtraBundle\Command\Command and it extends the ContainerAwareCommand provided by Symfony's framework bundle.

By extending the class you can call three methods in the configure method:

  • isSingleProcessed(): This sets a flag indicating that this command can only run one at a time. Useful when you're starting the command with a cronjob, preventing multiple running instances. Requires the posix extension loaded.
  • disableLoggers(): By default, a lot of information is being logged. If you don't need this information, or want your command to consume less memory (this depends on your setup of course, YMMV), this turns off logging for Doctrine and the default logger service.
  • setSummarizeDefinition(): For now, only the time and memory consumed are logged at the beginning and end of the command. This method controls which of these are logged. Both are logged by default.


protected function configure()
        ->setSummarizeDefinition(array('memory' => false))

For tips and/or feature requests, please don't hesitate to add an issue.