PHP Class Banago\PHPloy\PHPloy

Exibir arquivo Open project: banago/phploy

Public Properties

Property Type Description
$cli League\CLImate\CLImate
$copyDirs array
$currentlyDeploying string Keep track of which server we are currently deploying to.
$dotRevisionFilename string The name of the file on remote servers that stores the current revision hash.
$filesToExclude array A list of files that should NOT be uploaded to the named server.
$filesToInclude A list of patterns that a file MUST match to be uploaded to the remote server.
$git Git
$globalFilesToExclude array A list of files that should NOT be uploaded to any of the servers.
$hooks array
$iniFilename string The filename from which to read remote server details.
$localRevision string
$passFile string The filename from which to read server password.
$postDeploy array
$postDeployRemote array
$preDeploy array
$preDeployRemote array
$purgeDirs array
$revision string
$scanSubSubmodules boolean If you need support for sub-submodules, ensure this is set to TRUE Set to false when the --exclude-subsubmodules command line option is used.
$scanSubmodules boolean To activate submodule deployment use the --submodules argument.
$servers array
$submodules array

Protected Properties

Property Type Description
$connection League\Flysystem\Filesystem;
$currentSubmoduleName boolean | string
$debug boolean Whether to print extra debugging info to the console, especially for git & FTP commands Activated using --debug command line option.
$defaultServer boolean Keep track of if a default server has been configured.
$deployAll Weather the --all command line option was given.
$deploymentSize integer Keep track of current deployment size.
$dotRevision string Holds the path to the .revision file For the main repository this will be the value of $dotRevisionFilename ('.revision' by default) but for submodules, the submodule path will be prepended.
$init Whether the --init command line option was given.
$listFiles boolean Whether phploy is running in list mode (--list or -l commands).
$mainRepo string
$repo string
$server string
$sync boolean Whether the --sync command line option was given.
$version string

Public Methods

Method Description
__construct ( ) Constructor.
checkSubSubmodules ( string $repo, string $name ) Check for sub-submodules.
checkSubmodules ( string $repo ) Check for submodules.
compare ( string $localRevision ) : array Compare revisions and returns array of files to upload:.
copy ( $copyDirs ) Copy given directory's contents.
debug ( string $message ) Helper method to output messages to the console (only in debug mode) Debug mode is activated by setting $this->debug = true or using the command line option --debug.
deploy ( ) Deploy (or list) changed files.
directoryToArray ( string $directory, boolean $recursive = true, boolean $listDirs = false, boolean $listFiles = true, string $exclude = '' ) : array Get an array that represents directory tree Credit: http://php.net/manual/en/function.scandir.php#109140.
executeOnRemoteServer ( array $commands )
getPasswordFile ( ) : string Returns the full path to password file.
getPasswordFromIniFile ( string $servername ) : string Try to fetch password from .phploy file if not found, an empty string will be returned.
hasDeletedDirectories ( array $filesToDelete ) : array Checks for deleted directories. Git cares only about files.
humanFilesize ( integer $bytes, integer $decimals = 2 ) : string Return a human readable filesize.
listFiles ( array $files ) Check what files will be uploaded/deleted.
parseIniFile ( string $iniFile ) : array Parse an ini file and return values as array.
patternMatch ( string $pattern, string $string ) : string Glob the file path.
postDeploy ( array $commands ) Execute post commands.
postDeployRemote ( array $commands ) Execute post commands on remote server.
preDeploy ( array $commands ) Execute pre commands.
preDeployRemote ( array $commands ) Execute pre commands on remote server.
prepareServers ( ) Reads the phploy.ini file and populates the $this->servers array.
purge ( $purgeDirs ) Purge given directory's contents.
push ( array $files, $localRevision = null ) Update the current remote server with the array of files provided.
setRevision ( $localRevision = null ) Sets revision on the server.
setup ( ) Setup CLI options.

Protected Methods

Method Description
createSampleIniFile ( ) Creates sample ini file.
log ( string $message, string $type = 'INFO' ) Log a message to file.
relPath ( string $el ) : string Strip Absolute Path.

Private Methods

Method Description
currentBranch ( ) : string Gets the current branch name.
currentRevision ( ) : string Get current revision.
filterIgnoredFiles ( array $files ) : array Filter ignore files.
filterIncludedFiles ( array $files ) : array Filter included files.
getPassword ( ) : string Gets the password from user input, hiding password and replaces it with stars (*) if user users Unix / Mac.

Method Details

__construct() public method

Constructor.
public __construct ( )

checkSubSubmodules() public method

Check for sub-submodules.
public checkSubSubmodules ( string $repo, string $name )
$repo string
$name string

checkSubmodules() public method

Check for submodules.
public checkSubmodules ( string $repo )
$repo string

compare() public method

[ 'upload' => $filesToUpload, 'delete' => $filesToDelete ];
public compare ( string $localRevision ) : array
$localRevision string
return array

copy() public method

Copy given directory's contents.
public copy ( $copyDirs )

createSampleIniFile() protected method

Creates sample ini file.
protected createSampleIniFile ( )

debug() public method

Helper method to output messages to the console (only in debug mode) Debug mode is activated by setting $this->debug = true or using the command line option --debug.
public debug ( string $message )
$message string Message to display on the console

deploy() public method

Deploy (or list) changed files.
public deploy ( )

directoryToArray() public method

Get an array that represents directory tree Credit: http://php.net/manual/en/function.scandir.php#109140.
public directoryToArray ( string $directory, boolean $recursive = true, boolean $listDirs = false, boolean $listFiles = true, string $exclude = '' ) : array
$directory string Directory path
$recursive boolean Include sub directories
$listDirs boolean Include directories on listing
$listFiles boolean Include files on listing
$exclude string Exclude paths that matches this regex
return array

executeOnRemoteServer() public method

public executeOnRemoteServer ( array $commands )
$commands array

getPasswordFile() public method

Returns the full path to password file.
public getPasswordFile ( ) : string
return string

getPasswordFromIniFile() public method

Try to fetch password from .phploy file if not found, an empty string will be returned.
public getPasswordFromIniFile ( string $servername ) : string
$servername string Server to fetch password for
return string

hasDeletedDirectories() public method

Checks for deleted directories. Git cares only about files.
public hasDeletedDirectories ( array $filesToDelete ) : array
$filesToDelete array
return array

humanFilesize() public method

Return a human readable filesize.
public humanFilesize ( integer $bytes, integer $decimals = 2 ) : string
$bytes integer
$decimals integer
return string

listFiles() public method

Check what files will be uploaded/deleted.
public listFiles ( array $files )
$files array

log() protected method

Log a message to file.
protected log ( string $message, string $type = 'INFO' )
$message string The message to write
$type string The type of log message (e.g. INFO, DEBUG, ERROR, etc.)

parseIniFile() public method

Parse an ini file and return values as array.
public parseIniFile ( string $iniFile ) : array
$iniFile string
return array

patternMatch() public method

Glob the file path.
public patternMatch ( string $pattern, string $string ) : string
$pattern string
$string string
return string

postDeploy() public method

Execute post commands.
public postDeploy ( array $commands )
$commands array

postDeployRemote() public method

Execute post commands on remote server.
public postDeployRemote ( array $commands )
$commands array

preDeploy() public method

Execute pre commands.
public preDeploy ( array $commands )
$commands array

preDeployRemote() public method

Execute pre commands on remote server.
public preDeployRemote ( array $commands )
$commands array

prepareServers() public method

Reads the phploy.ini file and populates the $this->servers array.
public prepareServers ( )

purge() public method

Purge given directory's contents.
public purge ( $purgeDirs )

push() public method

Update the current remote server with the array of files provided.
public push ( array $files, $localRevision = null )
$files array 2-dimensional array with 2 indices: 'upload' and 'delete' Each of these contains an array of filenames and paths (relative to repository root)

relPath() protected method

Strip Absolute Path.
protected relPath ( string $el ) : string
$el string
return string

setRevision() public method

Sets revision on the server.
public setRevision ( $localRevision = null )

setup() public method

Setup CLI options.
public setup ( )

Property Details

$cli public_oe property

public CLImate,League\CLImate $cli
return League\CLImate\CLImate

$connection protected_oe property

protected Filesystem;,League\Flysystem $connection
return League\Flysystem\Filesystem;

$copyDirs public_oe property

public array $copyDirs
return array

$currentSubmoduleName protected_oe property

protected bool|string $currentSubmoduleName
return boolean | string

$currentlyDeploying public_oe property

Keep track of which server we are currently deploying to.
public string $currentlyDeploying
return string

$debug protected_oe property

Whether to print extra debugging info to the console, especially for git & FTP commands Activated using --debug command line option.
protected bool $debug
return boolean

$defaultServer protected_oe property

Keep track of if a default server has been configured.
protected bool $defaultServer
return boolean

$deployAll protected_oe property

Weather the --all command line option was given.
protected $deployAll

$deploymentSize protected_oe property

Keep track of current deployment size.
protected int $deploymentSize
return integer

$dotRevision protected_oe property

Holds the path to the .revision file For the main repository this will be the value of $dotRevisionFilename ('.revision' by default) but for submodules, the submodule path will be prepended.
protected string $dotRevision
return string

$dotRevisionFilename public_oe property

The name of the file on remote servers that stores the current revision hash.
public string $dotRevisionFilename
return string

$filesToExclude public_oe property

A list of files that should NOT be uploaded to the named server.
public array $filesToExclude
return array

$filesToInclude public_oe property

A list of patterns that a file MUST match to be uploaded to the remote server.
public $filesToInclude

$git public_oe property

public Git,Banago\PHPloy $git
return Git

$globalFilesToExclude public_oe property

A list of files that should NOT be uploaded to any of the servers.
public array $globalFilesToExclude
return array

$hooks public_oe property

public array $hooks
return array

$iniFilename public_oe property

The filename from which to read remote server details.
public string $iniFilename
return string

$init protected_oe property

Whether the --init command line option was given.
protected $init

$listFiles protected_oe property

Whether phploy is running in list mode (--list or -l commands).
protected bool $listFiles
return boolean

$localRevision public_oe property

public string $localRevision
return string

$mainRepo protected_oe property

protected string $mainRepo
return string

$passFile public_oe property

The filename from which to read server password.
public string $passFile
return string

$postDeploy public_oe property

public array $postDeploy
return array

$postDeployRemote public_oe property

public array $postDeployRemote
return array

$preDeploy public_oe property

public array $preDeploy
return array

$preDeployRemote public_oe property

public array $preDeployRemote
return array

$purgeDirs public_oe property

public array $purgeDirs
return array

$repo protected_oe property

protected string $repo
return string

$revision public_oe property

public string $revision
return string

$scanSubSubmodules public_oe property

If you need support for sub-submodules, ensure this is set to TRUE Set to false when the --exclude-subsubmodules command line option is used.
public bool $scanSubSubmodules
return boolean

$scanSubmodules public_oe property

To activate submodule deployment use the --submodules argument.
public bool $scanSubmodules
return boolean

$server protected_oe property

protected string $server
return string

$servers public_oe property

public array $servers
return array

$submodules public_oe property

public array $submodules
return array

$sync protected_oe property

Whether the --sync command line option was given.
protected bool $sync
return boolean

$version protected_oe property

protected string $version
return string