PHP Class VisualAppeal\AutoUpdate

ファイルを表示 Open project: visualappeal/php-auto-update Class Usage Examples

Public Properties

Property Type Description
$dirPermissions integer Create new folders with this privileges.
$updateScriptName string Update script filename.

Protected Properties

Property Type Description
$_currentVersion vierbergenlars\SemVer\version Current version.
$_updateFile string Version filename on the server.
$_updateUrl string Url to the update folder on the server.

Public Methods

Method Description
__construct ( string $tempDir = null, string $installDir = null, integer $maxExecutionTime = 60 ) Create new instance
addLogHandler ( Monolog\Handler\HandlerInterface $handler ) Add a new logging handler.
addTrailingSlash ( string $dir ) : string Add slash at the end of the path.
checkUpdate ( ) : integer | boolean Check for a new version
getLatestVersion ( ) : vierbergenlars\SemVer\version Get the name of the latest version.
getSimulationResults ( ) : array Get the results of the last simulation.
getVersionsToUpdate ( ) : array Get an array of versions which will be installed.
newVersionAvailable ( ) : boolean Check if a new version is available.
setBasicAuth ( $username, $password ) Set authentication
setBranch ( $branch ) Set the update branch.
setCache ( Desarrolla2\Cache\Adapter\AdapterInterface $adapter, integer $ttl = 3600 ) Set the cache component.
setCurrentVersion ( string $currentVersion ) : boolean Set the version of the current installed software.
setInstallDir ( string $dir ) Set the install directory.
setTempDir ( string $dir ) Set the temporary download directory.
setUpdateFile ( string $updateFile ) Set the update filename.
setUpdateUrl ( string $updateUrl ) Set the update filename.
update ( boolean $simulateInstall = true, boolean $deleteDownload = true ) : mixed Update to the latest version

Protected Methods

Method Description
_downloadUpdate ( string $updateUrl, string $updateFile ) : boolean Download the update
_install ( string $updateFile, boolean $simulateInstall, $version ) : boolean Install update.
_simulateInstall ( string $updateFile ) : boolean Simulate update process.

Private Methods

Method Description
_removeDir ( string $dir ) : void Remove directory recursively.
_useBasicAuth ( ) : null | resource Set authentication in update method of users and password exist

Method Details

__construct() public method

Create new instance
public __construct ( string $tempDir = null, string $installDir = null, integer $maxExecutionTime = 60 )
$tempDir string
$installDir string
$maxExecutionTime integer

_downloadUpdate() protected method

Download the update
protected _downloadUpdate ( string $updateUrl, string $updateFile ) : boolean
$updateUrl string Url where to download from
$updateFile string Path where to save the download
return boolean

_install() protected method

Install update.
protected _install ( string $updateFile, boolean $simulateInstall, $version ) : boolean
$updateFile string Path to the update file
$simulateInstall boolean Check for directory and file permissions before copying files
return boolean

_simulateInstall() protected method

Simulate update process.
protected _simulateInstall ( string $updateFile ) : boolean
$updateFile string
return boolean

addLogHandler() public method

Add a new logging handler.
public addLogHandler ( Monolog\Handler\HandlerInterface $handler )
$handler Monolog\Handler\HandlerInterface See https://github.com/Seldaek/monolog

addTrailingSlash() public method

Add slash at the end of the path.
public addTrailingSlash ( string $dir ) : string
$dir string
return string

checkUpdate() public method

Check for a new version
public checkUpdate ( ) : integer | boolean
return integer | boolean true: New version is available false: Error while checking for update int: Status code (i.e. AutoUpdate::NO_UPDATE_AVAILABLE)

getLatestVersion() public method

Get the name of the latest version.
public getLatestVersion ( ) : vierbergenlars\SemVer\version
return vierbergenlars\SemVer\version

getSimulationResults() public method

Get the results of the last simulation.
public getSimulationResults ( ) : array
return array

getVersionsToUpdate() public method

Get an array of versions which will be installed.
public getVersionsToUpdate ( ) : array
return array

newVersionAvailable() public method

Check if a new version is available.
public newVersionAvailable ( ) : boolean
return boolean

setBasicAuth() public method

Set authentication
public setBasicAuth ( $username, $password )
$username
$password

setBranch() public method

Set the update branch.
public setBranch ( $branch )

setCache() public method

Set the cache component.
public setCache ( Desarrolla2\Cache\Adapter\AdapterInterface $adapter, integer $ttl = 3600 )
$adapter Desarrolla2\Cache\Adapter\AdapterInterface See https://github.com/desarrolla2/Cache
$ttl integer Time to live in seconds

setCurrentVersion() public method

Set the version of the current installed software.
public setCurrentVersion ( string $currentVersion ) : boolean
$currentVersion string
return boolean

setInstallDir() public method

Set the install directory.
public setInstallDir ( string $dir )
$dir string

setTempDir() public method

Set the temporary download directory.
public setTempDir ( string $dir )
$dir string

setUpdateFile() public method

Set the update filename.
public setUpdateFile ( string $updateFile )
$updateFile string

setUpdateUrl() public method

Set the update filename.
public setUpdateUrl ( string $updateUrl )
$updateUrl string

update() public method

Update to the latest version
public update ( boolean $simulateInstall = true, boolean $deleteDownload = true ) : mixed
$simulateInstall boolean Check for directory and file permissions before copying files (Default: true)
$deleteDownload boolean Delete download after update (Default: true)
return mixed integer|bool

Property Details

$_currentVersion protected_oe property

Current version.
protected version,vierbergenlars\SemVer $_currentVersion
return vierbergenlars\SemVer\version

$_updateFile protected_oe property

Version filename on the server.
protected string $_updateFile
return string

$_updateUrl protected_oe property

Url to the update folder on the server.
protected string $_updateUrl
return string

$dirPermissions public_oe property

Create new folders with this privileges.
public int $dirPermissions
return integer

$updateScriptName public_oe property

Update script filename.
public string $updateScriptName
return string