SetupController

Type
Class
Namespace
craft\console\controllers
Inherits
craft\console\controllers\SetupController » yii\console\Controller » yii\base\Controller » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable, yii\base\ViewContextInterface
Since
3.0

Craft CMS setup installer.

View source

Public Properties

PropertyDescription
$actionyii\base\Action – The action that is currently being executed.
$behaviorsyii\base\Behavior – List of behaviors attached to this component
$colorboolean – Whether to enable ANSI color in the output.
$databasestring, null – The name of the database to select.
$defaultActionstring – The ID of the action that is used when the action ID is not specified in the request.
$driverstring, null – The database driver to use.
$helpboolean – Whether to display help information about current command.
$helpSummarystring
$idstring – The ID of this controller.
$interactiveboolean – Whether to run the command interactively.
$layoutnull, string, false – The name of the layout to be applied to this controller's views.
$moduleyii\base\Module – The module that this controller belongs to.
$modulesyii\base\Module – All ancestor modules that this controller is located within.
$passedOptionValuesarray – The properties corresponding to the passed options
$passedOptionsarray – The names of the options passed during execution
$passwordstring, null – The database password to connect with.
$portinteger, null – The database server port.
$routestring – The route (module ID, controller ID and action ID) of the current request.
$schemastring, null – The database schema to use (PostgreSQL only).
$serverstring, null – The database server name or IP address.
$tablePrefixstring, null – The table prefix to add to all database tables.
$uniqueIdstring – The controller ID that is prefixed with the module ID (if any).
$userstring, null – The database username to connect with.
$viewyii\base\View, yii\web\View – The view object that can be used to render views or view files.
$viewPathstring – The directory containing the view files for this controller.

$database

Type
string, null

The name of the database to select.

View source

Signature

public string, null $database = null

$driver

Type
string, null

The database driver to use. Either 'mysql' for MySQL or 'pgsql' for PostgreSQL.

View source

Signature

public string, null $driver = null

$password

Type
string, null

The database password to connect with.

View source

Signature

public string, null $password = null

$port

Type
integer, null

The database server port. Defaults to 3306 for MySQL and 5432 for PostgreSQL.

View source

Signature

public integer, null $port = 0

$schema

Type
string, null

The database schema to use (PostgreSQL only).

See also https://www.postgresql.org/docs/8.2/static/ddl-schemas.html

View source

Signature

public string, null $schema = null

$server

Type
string, null

The database server name or IP address. Usually 'localhost' or '127.0.0.1'.

View source

Signature

public string, null $server = null

$tablePrefix

Type
string, null

The table prefix to add to all database tables. This can be no more than 5 characters, and must be all lowercase.

View source

Signature

public string, null $tablePrefix = null

$user

Type
string, null

The database username to connect with.

View source

Signature

public string, null $user = null

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
actionDb()Alias for setup/db-creds.
actionDbCreds()Stores new DB connection settings to the .env file.
actionIndex()Sets up all the things.
actionSecurityKey()Generates a new security key and saves it in the .env file.
actionWelcome()Called from the post-create-project-cmd Composer hook.
actions()Declares external actions for the controller.
afterAction()This method is invoked right after an action is executed.
ansiFormat()Formats a string with ANSI codes.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
beforeAction()This method is invoked right before an action is executed.
behaviors()Returns a list of behaviors that this component should behave as.
bindActionParams()Binds the parameters to the action.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
confirm()Asks user to confirm by typing y or n.
createAction()Creates an action based on the given action ID.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
findLayoutFile()Finds the applicable layout file.
getActionArgsHelp()Returns the help information for the anonymous arguments for the action.
getActionHelp()Returns the detailed help information for the specified action.
getActionHelpSummary()Returns a one-line short summary describing the specified action.
getActionOptionsHelp()Returns the help information for the options for the action.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getHelp()Returns help information for this controller.
getHelpSummary()Returns one-line short summary describing this controller.
getModules()Returns all ancestor modules of this controller.
getOptionValues()Returns properties corresponding to the options for the action id Child classes may override this method to specify possible properties.
getPassedOptionValues()Returns the properties corresponding to the passed options.
getPassedOptions()Returns the names of valid options passed during execution.
getRoute()Returns the route of the current request.
getUniqueId()Returns the unique ID of the controller.
getView()Returns the view object that can be used to render views or view files.
getViewPath()Returns the directory containing view files for this controller.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
isColorEnabled()Returns a value indicating whether ANSI color is enabled.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
optionAliases()Returns option alias names.
options()Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name.
prompt()Prompts the user for input and validates it.
render()Renders a view and applies layout if available.
renderContent()Renders a static string by applying a layout.
renderFile()Renders a view file.
renderPartial()Renders a view without applying layout.
run()Runs a request specified in terms of a route.
runAction()Runs an action within this controller with the specified action ID and parameters.
select()Gives the user an option to choose from. Giving '?' as an input will show a list of options to choose from and their explanations.
setView()Sets the view object to be used by this controller.
setViewPath()Sets the directory that contains the view files.
stderr()Prints a string to STDERR.
stdout()Prints a string to STDOUT.
trigger()Triggers an event.

actionDb()

Alias for setup/db-creds.

View source

Returns

integer

Signature

public integer actionDb ( )

actionDbCreds()

Stores new DB connection settings to the .env file.

View source

Returns

integer

Signature

public integer actionDbCreds ( )

actionIndex()

Sets up all the things.

View source

Returns

integer

Signature

public integer actionIndex ( )

actionSecurityKey()

Generates a new security key and saves it in the .env file.

View source

Returns

integer

Signature

public integer actionSecurityKey ( )

actionWelcome()

Called from the post-create-project-cmd Composer hook.

View source

Returns

integer

Signature

public integer actionWelcome ( )

options()

Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name.

Child classes may override this method to specify possible options.

Note that the values setting via options are not available until beforeAction() is being called.

View source

Arguments

  • $actionID (string) – The action id of the current request

Returns

string[] – The names of the options valid for the action

Signature

public string[] options ( $actionID )

Protected Methods

MethodDescription
getActionMethodReflection()
parseDocCommentDetail()Returns full description from the docblock.
parseDocCommentSummary()Returns the first line of docblock.
parseDocCommentTags()Parses the comment block into tags.

Constants

ConstantDescription
EXIT_CODE_ERROR
EXIT_CODE_NORMAL