[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/splitbrain/php-cli/src/ -> CLI.php (summary)

(no description)

File Size: 362 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CLI:: (20 methods):
  __construct()
  run()
  registerDefaultOptions()
  handleDefaultOptions()
  setupLogging()
  parseOptions()
  checkArgments()
  execute()
  fatal()
  emergency()
  alert()
  critical()
  error()
  warning()
  success()
  notice()
  info()
  debug()
  log()
  interpolate()


Class: CLI  - X-Ref

Class CLI

Your commandline script should inherit from this class and implement the abstract methods.

__construct($autocatch = true)   X-Ref
constructor

Initialize the arguments, set up helper classes and set up the CLI environment

param: bool $autocatch should exceptions be catched and handled automatically?

run()   X-Ref
Execute the CLI program

Executes the setup() routine, adds default options, initiate the options parsing and argument checking
and finally executes main() - Each part is split into their own protected function below, so behaviour
can easily be overwritten


registerDefaultOptions()   X-Ref
Add the default help, color and log options


handleDefaultOptions()   X-Ref
Handle the default options


setupLogging()   X-Ref
Handle the logging options


parseOptions()   X-Ref
Wrapper around the option parsing


checkArgments()   X-Ref
Wrapper around the argument checking


execute()   X-Ref
Wrapper around main


fatal($error, array $context = array()   X-Ref
Exits the program on a fatal error

param: \Exception|string $error either an exception or an error message
param: array $context

emergency($message, array $context = array()   X-Ref
System is unusable.

return: void
param: string $message
param: array $context

alert($message, array $context = array()   X-Ref
Action must be taken immediately.

Example: Entire website down, database unavailable, etc. This should
trigger the SMS alerts and wake you up.

param: string $message
param: array $context

critical($message, array $context = array()   X-Ref
Critical conditions.

Example: Application component unavailable, unexpected exception.

param: string $message
param: array $context

error($message, array $context = array()   X-Ref
Runtime errors that do not require immediate action but should typically
be logged and monitored.

param: string $message
param: array $context

warning($message, array $context = array()   X-Ref
Exceptional occurrences that are not errors.

Example: Use of deprecated APIs, poor use of an API, undesirable things
that are not necessarily wrong.

param: string $message
param: array $context

success($string, array $context = array()   X-Ref
Normal, positive outcome

param: string $string
param: array $context

notice($message, array $context = array()   X-Ref
Normal but significant events.

param: string $message
param: array $context

info($message, array $context = array()   X-Ref
Interesting events.

Example: User logs in, SQL logs.

param: string $message
param: array $context

debug($message, array $context = array()   X-Ref
Detailed debug information.

param: string $message
param: array $context

log($level, $message, array $context = array()   X-Ref

param: string $level
param: string $message
param: array $context

interpolate($message, array $context = array()   X-Ref
Interpolates context values into the message placeholders.

return: string
param: $message
param: array $context