PHP Класс yii2tech\selfupdate\SelfUpdateController

You can configure available version control systems via [[versionControlSystems]]. Note: in order to work properly this command requires execution of VCS command without any prompt or user input. Usage: 1. Create a configuration file using the config action: yii self-update/config @app/config/selfupdate.php 2. Edit the created config file, adjusting it for your project needs. 3. Run the 'perform' action, using created config: yii self-update @app/config/selfupdate.php
С версии: 1.0
Автор: Paul Klimov ([email protected])
Наследование: extends yii\console\Controller
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$afterUpdateCommands list of shell commands, which should be executed after project update. If command is a string it will be executed as shell command, otherwise as PHP callback. For example: php [ 'php /path/to/project/yii migrate/up --interactive=0' ],
$beforeUpdateCommands list of commands, which should be executed before project update begins. If command is a string it will be executed as shell command, otherwise as PHP callback. For example: php [ 'mysqldump -h localhost -u root myproject > /path/to/backup/myproject.sql' ],
$cache list of cache application components, for which [[Cache::flush()]] method should be invoked. Component ids, instances or array configurations can be used here.
$composerBinPath path to the 'composer' bin command. By default simple 'composer' is used, assuming it available as global shell command. Path alias can be used here. For example: '@app/composer.phar'.
$composerOptions composer command options.
$composerRootPaths list of composer install root paths (the ones containing 'composer.json'). Path aliases can be used here.
$configFile configuration file name. Settings from this file will be merged with the default ones. Such configuration file can be created, using action 'config'. Path alias can be used here, for example: '@app/config/self-update.php'.
$defaultAction controller default action ID.
$emails list of email addresses, which should be used to send execution reports.
$mailer the mailer object or the application component ID of the mailer. It will be used to send notification messages to [[emails]]. If not set or sending email via this component fails, the fallback to the plain PHP mail() function will be used instead.
$mutex the mutex object or the application component ID of the mutex. After the controller object is created, if you want to change this property, you should only assign it with a mutex connection object.
$projectRootPath path to project root directory, which means VCS root directory. Path aliases can be use here.
$shellResponseErrorKeywords list of keywords, which presence in the shell command output is considered as its execution error.
$tmpDirectories list of temporary directories, which should be cleared after project update. Path aliases can be used here. For example: php [ '@app/web/assets', '@runtime/URI', '@runtime/HTML', '@runtime/debug', ]
$versionControlSystems list of possible version control systems (VCS) in format: vcsFolderName => classConfig. VCS will be detected automatically based on which folder is available inside [[projectRootPath]]
$webPaths project web path stubs configuration. Each path configuration should have following keys: - 'path' - string - path to web root folder - 'link' - string - path for the symbolic link, which should point to the web root - 'stub' - string - path to folder, which contains stub for the web Yii aliases can be used for all these keys. For example: php [ [ 'path' => '@app/web', 'link' => '@app/httpdocs', 'stub' => '@app/webstub', ] ]

Открытые методы

Метод Описание
actionConfig ( string $fileName ) : integer Creates a configuration file for the "perform" command.
actionPerform ( string | null $configFile = null ) : integer Performs project update from VCS.
getCurrentDate ( ) : string
getHostName ( ) : string
getReportFrom ( ) : string
setHostName ( string $hostName )
setReportFrom ( string $reportFrom )

Защищенные методы

Метод Описание
acquireMutex ( ) : boolean Acquires current action lock.
clearDirectory ( string $dir ) Clears specified directory.
clearTmpDirectories ( ) Clears all directories specified via [[tmpDirectories]].
composeMutexName ( ) : string Composes the mutex name.
detectVersionControlSystem ( string $path ) : yii2tech\selfupdate\VersionControlSystemInterface Detects version control system used for the project.
execShellCommand ( string $command, array $placeholders = [] ) : string Executes shell command.
executeCommands ( array $commands ) Executes list of given commands.
flushCache ( ) Flushes cache for all components specified at [[cache]].
flushLog ( ) : array Flushes log lines, returning them.
linkWebPaths ( ) Links web roots to the actual web directories.
linkWebStubs ( ) Links web roots to the stub directories.
log ( string $message ) Logs the message
normalizeWebPaths ( ) Normalizes [[webPaths]] value.
releaseMutex ( ) : boolean Release current action lock.
reportFail ( ) Sends report about failure.
reportResult ( string $subjectPrefix ) Sends execution report.
reportSuccess ( ) Sends report about success.
sendEmail ( string $from, string $email, string $subject, string $message ) : boolean Sends an email.
sendEmailFallback ( string $from, string $email, string $subject, string $message ) : boolean Sends an email via plain PHP mail() function.
updateVendor ( ) Performs vendors update via Composer at all [[composerRootPaths]].

Описание методов

acquireMutex() защищенный Метод

Acquires current action lock.
protected acquireMutex ( ) : boolean
Результат boolean lock acquiring result.

actionConfig() публичный Метод

The generated configuration file contains detailed instructions on how to customize it to fit for your needs. After customization, you may use this configuration file with the "perform" command.
public actionConfig ( string $fileName ) : integer
$fileName string output file name or alias.
Результат integer CLI exit code

actionPerform() публичный Метод

Performs project update from VCS.
public actionPerform ( string | null $configFile = null ) : integer
$configFile string | null the path or alias of the configuration file. You may use the "config" command to generate this file and then customize it for your needs.
Результат integer CLI exit code

clearDirectory() защищенный Метод

Clears specified directory.
protected clearDirectory ( string $dir )
$dir string directory to be cleared.

clearTmpDirectories() защищенный Метод

Clears all directories specified via [[tmpDirectories]].
protected clearTmpDirectories ( )

composeMutexName() защищенный Метод

Composes the mutex name.
protected composeMutexName ( ) : string
Результат string mutex name.

detectVersionControlSystem() защищенный Метод

Detects version control system used for the project.
protected detectVersionControlSystem ( string $path ) : yii2tech\selfupdate\VersionControlSystemInterface
$path string project root path.
Результат yii2tech\selfupdate\VersionControlSystemInterface version control system instance.

execShellCommand() защищенный Метод

Executes shell command.
protected execShellCommand ( string $command, array $placeholders = [] ) : string
$command string command text.
$placeholders array placeholders to be replaced using `escapeshellarg()` in format: placeholder => value.
Результат string command output.

executeCommands() защищенный Метод

Executes list of given commands.
protected executeCommands ( array $commands )
$commands array commands to be executed.

flushCache() защищенный Метод

Flushes cache for all components specified at [[cache]].
protected flushCache ( )

flushLog() защищенный Метод

Flushes log lines, returning them.
protected flushLog ( ) : array
Результат array log lines.

getCurrentDate() публичный Метод

public getCurrentDate ( ) : string
Результат string current date string.

getHostName() публичный Метод

public getHostName ( ) : string
Результат string server hostname.

getReportFrom() публичный Метод

public getReportFrom ( ) : string
Результат string email address, which should be used to send report email messages.

linkWebPaths() защищенный Метод

Links web roots to the actual web directories.
См. также: webPaths
protected linkWebPaths ( )

linkWebStubs() защищенный Метод

Links web roots to the stub directories.
См. также: webPaths
protected linkWebStubs ( )

log() защищенный Метод

Logs the message
protected log ( string $message )
$message string log message.

normalizeWebPaths() защищенный Метод

Normalizes [[webPaths]] value.
protected normalizeWebPaths ( )

releaseMutex() защищенный Метод

Release current action lock.
protected releaseMutex ( ) : boolean
Результат boolean lock release result.

reportFail() защищенный Метод

Sends report about failure.
protected reportFail ( )

reportResult() защищенный Метод

Report message content will be composed from log messages.
protected reportResult ( string $subjectPrefix )
$subjectPrefix string report message subject.

reportSuccess() защищенный Метод

Sends report about success.
protected reportSuccess ( )

sendEmail() защищенный Метод

Sends an email.
protected sendEmail ( string $from, string $email, string $subject, string $message ) : boolean
$from string sender email address
$email string single email address
$subject string email subject
$message string email content
Результат boolean success.

sendEmailFallback() защищенный Метод

Sends an email via plain PHP mail() function.
protected sendEmailFallback ( string $from, string $email, string $subject, string $message ) : boolean
$from string sender email address
$email string single email address
$subject string email subject
$message string email content
Результат boolean success.

setHostName() публичный Метод

public setHostName ( string $hostName )
$hostName string server hostname.

setReportFrom() публичный Метод

public setReportFrom ( string $reportFrom )
$reportFrom string email address, which should be used to send report email messages.

updateVendor() защищенный Метод

Performs vendors update via Composer at all [[composerRootPaths]].
protected updateVendor ( )

Описание свойств

$afterUpdateCommands публичное свойство

list of shell commands, which should be executed after project update. If command is a string it will be executed as shell command, otherwise as PHP callback. For example: php [ 'php /path/to/project/yii migrate/up --interactive=0' ],
public $afterUpdateCommands

$beforeUpdateCommands публичное свойство

list of commands, which should be executed before project update begins. If command is a string it will be executed as shell command, otherwise as PHP callback. For example: php [ 'mysqldump -h localhost -u root myproject > /path/to/backup/myproject.sql' ],
public $beforeUpdateCommands

$cache публичное свойство

list of cache application components, for which [[Cache::flush()]] method should be invoked. Component ids, instances or array configurations can be used here.
public $cache

$composerBinPath публичное свойство

path to the 'composer' bin command. By default simple 'composer' is used, assuming it available as global shell command. Path alias can be used here. For example: '@app/composer.phar'.
public $composerBinPath

$composerOptions публичное свойство

composer command options.
См. также: Shell::buildOptions() for valid syntax on specifying this value. For example: ```php [ 'prefer-dist', 'no-dev', ] ``` Note, that `no-interaction` option will be added automatically to the options list.
С версии: 1.0.2
public $composerOptions

$composerRootPaths публичное свойство

list of composer install root paths (the ones containing 'composer.json'). Path aliases can be used here.
public $composerRootPaths

$configFile публичное свойство

configuration file name. Settings from this file will be merged with the default ones. Such configuration file can be created, using action 'config'. Path alias can be used here, for example: '@app/config/self-update.php'.
public $configFile

$defaultAction публичное свойство

controller default action ID.
public $defaultAction

$emails публичное свойство

list of email addresses, which should be used to send execution reports.
public $emails

$mailer публичное свойство

the mailer object or the application component ID of the mailer. It will be used to send notification messages to [[emails]]. If not set or sending email via this component fails, the fallback to the plain PHP mail() function will be used instead.
public $mailer

$mutex публичное свойство

the mutex object or the application component ID of the mutex. After the controller object is created, if you want to change this property, you should only assign it with a mutex connection object.
public $mutex

$projectRootPath публичное свойство

path to project root directory, which means VCS root directory. Path aliases can be use here.
public $projectRootPath

$shellResponseErrorKeywords публичное свойство

list of keywords, which presence in the shell command output is considered as its execution error.
public $shellResponseErrorKeywords

$tmpDirectories публичное свойство

list of temporary directories, which should be cleared after project update. Path aliases can be used here. For example: php [ '@app/web/assets', '@runtime/URI', '@runtime/HTML', '@runtime/debug', ]
public $tmpDirectories

$versionControlSystems публичное свойство

list of possible version control systems (VCS) in format: vcsFolderName => classConfig. VCS will be detected automatically based on which folder is available inside [[projectRootPath]]
public $versionControlSystems

$webPaths публичное свойство

project web path stubs configuration. Each path configuration should have following keys: - 'path' - string - path to web root folder - 'link' - string - path for the symbolic link, which should point to the web root - 'stub' - string - path to folder, which contains stub for the web Yii aliases can be used for all these keys. For example: php [ [ 'path' => '@app/web', 'link' => '@app/httpdocs', 'stub' => '@app/webstub', ] ]
public $webPaths