Let the platform do the work

Console

Overview

The Console extension adds custom CLI commands to Sugar. More information on creating custom commands can be found in the CLI documentation.

Properties

The following extension properties are available. For more information, please refer to the Extension Property documentation.

Property Value
Extension Scope Application
Extension Directory ./custom/Extension/application/Ext/Console/
Compiled Extension File ./custom/application/Ext/Console/console.ext.php
Manifest Installdef $installdefs['console']

Implementation

The following sections illustrate the various ways to implement a customization to a Sugar instance.

File System

To create a Sugar console extension, please refer to our CLI documentation.

Module Loadable Package

When building a module loadable package, you can use the $installdefs['console'] index to install the extension file.

Installdef Properties

Name Type Description
from String The basepath of the file to be installed.

The example below demonstrates the proper install definition that should be used in the ./manifest.php file in order to add the console command. 

./manifest.php

<?php

$manifest = array(
    ...
);

$installdefs = array (
  'id' => 'console_Example',
  'console' => array(
      array(
          'from' => '<basepath>/Files/custom/Extension/application/Ext/Console/RegisterHelloWorldCommand.php'
      )
  ),
  'copy' => array (
    0 => array (
      'from' => '<basepath>/Files/custom/src/Console/Command/HelloWorldCommand.php',
      'to' => 'custom/src/Console/Command/HelloWorldCommand.php',
    ),
  ),
);

Alternatively, you may use the $installdefs['copy'] index to copy the file. When using this approach, you may need to manually run repair actions such as a Quick Repair and Rebuild. For more information on the $installdefs['copy'] index and module-loadable packages, please refer to the Introduction to the Manifest page.

Download the module loadable example package here.