Constants

QUIET

QUIET = 1

NORMAL

NORMAL = 2

VERBOSE

VERBOSE = 4

VERY_VERBOSE

VERY_VERBOSE = 8

DEBUG

DEBUG = 16

Methods

isInteractive()

isInteractive() : boolean

Is this input means interactive?

Returns

boolean

isVerbose()

isVerbose() : boolean

Is this output verbose?

Returns

boolean

isVeryVerbose()

isVeryVerbose() : boolean

Is the output very verbose?

Returns

boolean

isDebug()

isDebug() : boolean

Is the output in debug verbosity?

Returns

boolean

isDecorated()

isDecorated() : boolean

Is this output decorated?

Returns

boolean

write()

write(string|array  $messages, boolean  $newline = true, integer  $verbosity = self::NORMAL) 

Writes a message to the output.

Parameters

string|array $messages

The message as an array of lines or a single string

boolean $newline

Whether to add a newline or not

integer $verbosity

Verbosity level from the VERBOSITY_* constants

writeError()

writeError(string|array  $messages, boolean  $newline = true, integer  $verbosity = self::NORMAL) 

Writes a message to the error output.

Parameters

string|array $messages

The message as an array of lines or a single string

boolean $newline

Whether to add a newline or not

integer $verbosity

Verbosity level from the VERBOSITY_* constants

overwrite()

overwrite(string|array  $messages, boolean  $newline = true, integer  $size = null, integer  $verbosity = self::NORMAL) 

Overwrites a previous message to the output.

Parameters

string|array $messages

The message as an array of lines or a single string

boolean $newline

Whether to add a newline or not

integer $size

The size of line

integer $verbosity

Verbosity level from the VERBOSITY_* constants

overwriteError()

overwriteError(string|array  $messages, boolean  $newline = true, integer  $size = null, integer  $verbosity = self::NORMAL) 

Overwrites a previous message to the error output.

Parameters

string|array $messages

The message as an array of lines or a single string

boolean $newline

Whether to add a newline or not

integer $size

The size of line

integer $verbosity

Verbosity level from the VERBOSITY_* constants

ask()

ask(string  $question, string  $default = null) : string

Asks a question to the user.

Parameters

string $question

The question to ask

string $default

The default answer if none is given by the user

Throws

\RuntimeException

If there is no data to read in the input stream

Returns

string —

The user answer

askConfirmation()

askConfirmation(string  $question, boolean  $default = true) : boolean

Asks a confirmation to the user.

The question will be asked until the user answers by nothing, yes, or no.

Parameters

string $question

The question to ask

boolean $default

The default answer if the user enters nothing

Returns

boolean —

true if the user has confirmed, false otherwise

askAndValidate()

askAndValidate(string  $question, callable  $validator, null|integer  $attempts = null, mixed  $default = null) : mixed

Asks for a value and validates the response.

The validator receives the data to validate. It must return the validated data when the data is valid and throw an exception otherwise.

Parameters

string $question

The question to ask

callable $validator

A PHP callback

null|integer $attempts

Max number of times to ask before giving up (default of null means infinite)

mixed $default

The default answer if none is given by the user

Throws

\Exception

When any of the validators return an error

Returns

mixed

askAndHideAnswer()

askAndHideAnswer(string  $question) : string

Asks a question to the user and hide the answer.

Parameters

string $question

The question to ask

Returns

string —

The answer

select()

select(string  $question, array  $choices, boolean|string  $default, boolean|integer  $attempts = false, string  $errorMessage = 'Value "%s" is invalid', boolean  $multiselect = false) : integer|string|array

Asks the user to select a value.

Parameters

string $question

The question to ask

array $choices

List of choices to pick from

boolean|string $default

The default answer if the user enters nothing

boolean|integer $attempts

Max number of times to ask before giving up (false by default, which means infinite)

string $errorMessage

Message which will be shown if invalid value from choice list would be picked

boolean $multiselect

Select more than one value separated by comma

Throws

\InvalidArgumentException

Returns

integer|string|array —

The selected value or values (the key of the choices array)

getAuthentications()

getAuthentications() : array

Get all authentication information entered.

Returns

array —

The map of authentication data

hasAuthentication()

hasAuthentication(string  $repositoryName) : boolean

Verify if the repository has a authentication information.

Parameters

string $repositoryName

The unique name of repository

Returns

boolean

getAuthentication()

getAuthentication(string  $repositoryName) : array

Get the username and password of repository.

Parameters

string $repositoryName

The unique name of repository

Returns

array —

The 'username' and 'password'

setAuthentication()

setAuthentication(string  $repositoryName, string  $username, string  $password = null) 

Set the authentication information for the repository.

Parameters

string $repositoryName

The unique name of repository

string $username

The username

string $password

The password

loadConfiguration()

loadConfiguration(\Composer\Config  $config) 

Loads authentications from a config instance

Parameters

\Composer\Config $config