‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Utility\CommandUtility Class Reference

Static Public Member Functions

static exec (string $command, ?array &$output=null, int &$returnValue=0)
static string imageMagickCommand (string $command, string $parameters, string $path='')
static bool int checkCommand (string $cmd, string $handler='')
static string bool int getCommand (string $cmd, string $handler='', string $handlerOpt='')
static addPaths (string $paths)

Static Protected Attributes

static bool $initialized = false
static array $applications = []
static array $paths = null

Detailed Description

Class to handle system commands. finds executables (programs) on Unix and Windows without knowing where they are

returns exec command for a program or FALSE

This class is meant to be used without instance:

$cmd = ‪CommandUtility::getCommand ('awstats','perl');

The data of this class is cached. That means if a program is found once it don't have to be searched again.

user functions:

addPaths() could be used to extend the search paths getCommand() get a command string checkCommand() returns TRUE if a command is available

Search paths that are included: $TYPO3_CONF_VARS['GFX']['processor_path'] $TYPO3_CONF_VARS['SYS']['binPath'] $GLOBALS['_SERVER']['PATH'] '/usr/bin/,/usr/local/bin/' on Unix

binaries can be preconfigured with $TYPO3_CONF_VARS['SYS']['binSetup']

Definition at line 53 of file CommandUtility.php.

Member Function Documentation

◆ addPaths()

static TYPO3\CMS\Core\Utility\CommandUtility::addPaths ( string  $paths)

Extend the preset paths. This way an extension can install an executable and provide the path to \TYPO3\CMS\Core\Utility\CommandUtility

string$paths‪Comma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with public web path

Definition at line 273 of file CommandUtility.php.

References TYPO3\CMS\Core\Utility\CommandUtility\$paths.

◆ checkCommand()

static bool int TYPO3\CMS\Core\Utility\CommandUtility::checkCommand ( string  $cmd,
string  $handler = '' 

Checks if a command is valid or not, updates global variables

string$cmd‪The command that should be executed. eg: "convert"
string$handler‪Executor for the command. eg: "perl"
‪bool|int True if the command is valid; False if cmd is not found; -1 if the handler is not found

Definition at line 168 of file CommandUtility.php.

References $output, TYPO3\CMS\Core\Utility\PathUtility\dirname(), TYPO3\CMS\Core\Utility\CommandUtility\exec(), and TYPO3\CMS\Core\Core\Environment\isWindows().

Referenced by TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isServiceAvailable().

◆ exec()

◆ getCommand()

static string bool int TYPO3\CMS\Core\Utility\CommandUtility::getCommand ( string  $cmd,
string  $handler = '',
string  $handlerOpt = '' 

Returns a command string for exec(), system()

string$cmd‪The command that should be executed. eg: "convert"
string$handler‪Handler (executor) for the command. eg: "perl"
string$handlerOpt‪Options for the handler, like '-w' for "perl"
‪string|bool|int Returns command string, or FALSE if cmd is not found, or -1 if the handler is not found

Definition at line 243 of file CommandUtility.php.

◆ imageMagickCommand()

static string TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand ( string  $command,
string  $parameters,
string  $path = '' 

Compile the command for running ImageMagick/GraphicsMagick.

string$commandCommand to be run: identify, convert or combine/composite
string$parameters‪The parameters string
string$path‪Override the default path (e.g. used by the install tool)
‪string Compiled command that deals with ImageMagick & GraphicsMagick

Definition at line 98 of file CommandUtility.php.

References $GLOBALS, and TYPO3\CMS\Core\Core\Environment\isWindows().

Referenced by TYPO3\CMS\Install\Controller\EnvironmentController\determineImageMagickVersion().

Member Data Documentation

◆ $applications

array TYPO3\CMS\Core\Utility\CommandUtility::$applications = []

Definition at line 69 of file CommandUtility.php.

◆ $initialized

bool TYPO3\CMS\Core\Utility\CommandUtility::$initialized = false

Tells if object is already initialized

Definition at line 58 of file CommandUtility.php.

◆ $paths

array TYPO3\CMS\Core\Utility\CommandUtility::$paths = null

Definition at line 78 of file CommandUtility.php.

Referenced by TYPO3\CMS\Core\Utility\CommandUtility\addPaths().

‪static string bool int getCommand(string $cmd, string $handler='', string $handlerOpt='')
Definition: CommandUtility.php:243