Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


This page covers making command classes for fwconsole. The fwconsole is built with symfony console and their documentation can be referenced for using symfony internals.

 Skeleton File

The class should be  $WEBROOT/admin/modules/$MODULE/Console/Classname.class.php


Code Block
namespace FreePBX\Console\Command;


These are the base includes. You may have others depending on the components you use.


Code Block
titleMulti-use flag with argument
new InputOption('longname', 'l', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Help Text')



Code Block
	protected function execute(InputInterface $input, OutputInterface $output){
		$arg = $input->getArgument('args');
		$dlag = $input->getOption('flag');
		if ($input->getOption('flag')) {
			$text = "Flag Set.";
		} else {
			$text = "No Flag Set";
		if($dlag){ print_r($dlag);}

Module XML Lazy Loading

Starting in Framework 14.0.8 and Framework 15.0.7 Console commands now support "Lazy Loading". The Symfony Console (which is what FreePBX uses to do console commands) suffered a shortcoming since day one: you must instantiate all commands to register them in the console application. The reason is that even the command name itself is defined inside a method called configure(), so you must instantiate the command class to configure it and get the command name.

This means that for every "command" that was directly run the system would still load every single OTHER console command. With module XML loading this is not longer the case (and don't worry the system will fall back to the older method easily!)

See more here:

To get this working just add a console block to the module.xml file as follows:

Code Block
  • name: The name of the command, MUST be the same name you use in the method setName()
  • alias(es): The name of the aliases for this command, MUST be the same name(s) you set in the array of setAlias()
  • class: The name of the class file in the console/ folder to load for this. If not set then name is assumed. Resulting format would be: rawname/Console/<class>.class.php
    • EX: rawname/Console/Endpoint.class.php


Hooking in to fwconfig start/stop