Installer
in package
Class Installer
Table of Contents
Constants
- EXISTS = 1
- INVALID_SOURCE = 128
- IS_LINK = 2
- NOT_DIRECTORY = 8
- NOT_FOUND = 4
- NOT_GRAV_ROOT = 16
- OK = 0
- ZIP_EXTRACT_ERROR = 64
- ZIP_OPEN_ERROR = 32
Properties
- $error : int|string
- $error_zip : int
- $message : string
- $options : array<string|int, mixed>
- $target : string
Methods
- copyInstall() : bool
- getMessage() : string
- Returns the last message added by the installer
- install() : bool
- Installs a given package to a given destination.
- isGravInstance() : bool
- Validates if the given path is a Grav Instance
- isValidDestination() : bool
- Runs a set of checks on the destination and sets the Error if any
- lastErrorCode() : int|string
- Returns the last error code of the occurred error
- lastErrorMsg() : string
- Returns the last error occurred in a string message format
- moveInstall() : bool
- setError() : void
- Allows to manually set an error
- sophisticatedInstall() : bool
- uninstall() : bool
- Uninstalls one or more given package
- unZip() : string|false
- Unzip a file to somewhere
- loadInstaller() : string|null
- Instantiates and returns the package installer class
Constants
EXISTS
public
mixed
EXISTS
= 1
Tags
INVALID_SOURCE
public
mixed
INVALID_SOURCE
= 128
Tags
IS_LINK
public
mixed
IS_LINK
= 2
Tags
NOT_DIRECTORY
public
mixed
NOT_DIRECTORY
= 8
Tags
NOT_FOUND
public
mixed
NOT_FOUND
= 4
Tags
NOT_GRAV_ROOT
public
mixed
NOT_GRAV_ROOT
= 16
Tags
OK
public
mixed
OK
= 0
Tags
ZIP_EXTRACT_ERROR
public
mixed
ZIP_EXTRACT_ERROR
= 64
Tags
ZIP_OPEN_ERROR
public
mixed
ZIP_OPEN_ERROR
= 32
Tags
Properties
$error
protected
static int|string
$error
= 0
Error code or string
$error_zip
protected
static int
$error_zip
= 0
Zip Error Code
$message
protected
static string
$message
= ''
Post install message
$options
protected
static array<string|int, mixed>
$options
= ['overwrite' => true, 'ignore_symlinks' => true, 'sophisticated' => false, 'theme' => false, 'install_path' => '', 'ignores' => [], 'exclude_checks' => [self::EXISTS, self::NOT_FOUND, self::IS_LINK]]
Default options for the install
$target
protected
static string
$target
Destination folder on which validation checks are applied
Methods
copyInstall()
public
static copyInstall(string $source_path, string $install_path) : bool
Parameters
- $source_path : string
- $install_path : string
Return values
boolgetMessage()
Returns the last message added by the installer
public
static getMessage() : string
Return values
string —The message
install()
Installs a given package to a given destination.
public
static install(string $zip, string $destination[, array<string|int, mixed> $options = [] ][, string|null $extracted = null ][, bool $keepExtracted = false ]) : bool
Parameters
- $zip : string
-
the local path to ZIP package
- $destination : string
-
The local path to the Grav Instance
- $options : array<string|int, mixed> = []
-
Options to use for installing. ie, ['install_path' => 'user/themes/antimatter']
- $extracted : string|null = null
-
The local path to the extacted ZIP package
- $keepExtracted : bool = false
-
True if you want to keep the original files
Return values
bool —True if everything went fine, False otherwise.
isGravInstance()
Validates if the given path is a Grav Instance
public
static isGravInstance(string $target) : bool
Parameters
- $target : string
-
The local path to the Grav Instance
Return values
bool —True if is a Grav Instance. False otherwise
isValidDestination()
Runs a set of checks on the destination and sets the Error if any
public
static isValidDestination(string $destination[, array<string|int, mixed> $exclude = [] ]) : bool
Parameters
- $destination : string
-
The directory to run validations at
- $exclude : array<string|int, mixed> = []
-
An array of constants to exclude from the validation
Return values
bool —True if validation passed. False otherwise
lastErrorCode()
Returns the last error code of the occurred error
public
static lastErrorCode() : int|string
Return values
int|string —The code of the last error
lastErrorMsg()
Returns the last error occurred in a string message format
public
static lastErrorMsg() : string
Return values
string —The message of the last error
moveInstall()
public
static moveInstall(string $source_path, string $install_path) : bool
Parameters
- $source_path : string
- $install_path : string
Return values
boolsetError()
Allows to manually set an error
public
static setError(int|string $error) : void
Parameters
- $error : int|string
-
the Error code
sophisticatedInstall()
public
static sophisticatedInstall(string $source_path, string $install_path[, array<string|int, mixed> $ignores = [] ][, bool $keep_source = false ]) : bool
Parameters
- $source_path : string
- $install_path : string
- $ignores : array<string|int, mixed> = []
- $keep_source : bool = false
Return values
booluninstall()
Uninstalls one or more given package
public
static uninstall(string $path[, array<string|int, mixed> $options = [] ]) : bool
Parameters
- $path : string
-
The slug of the package(s)
- $options : array<string|int, mixed> = []
-
Options to use for uninstalling
Return values
bool —True if everything went fine, False otherwise.
unZip()
Unzip a file to somewhere
public
static unZip(string $zip_file, string $destination) : string|false
Parameters
- $zip_file : string
- $destination : string
Return values
string|falseloadInstaller()
Instantiates and returns the package installer class
private
static loadInstaller(string $installer_file_folder, bool $is_install) : string|null
Parameters
- $installer_file_folder : string
-
The folder path that contains install.php
- $is_install : bool
-
True if install, false if removal