2020-10-02 00:11:13 +02:00
<!-- DO NOT EDIT THIS FILE! -->
<!-- Instead edit src/functions.php -->
<!-- Then run bin/docgen -->
2020-09-30 15:35:44 +02:00
2020-09-30 09:29:02 +02:00
# API Reference
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
* [`host()` ](#host )
* [`localhost()` ](#localhost )
* [`getHost()` ](#getHost )
* [`currentHost()` ](#currentHost )
* [`inventory()` ](#inventory )
* [`desc()` ](#desc )
* [`task()` ](#task )
* [`before()` ](#before )
* [`after()` ](#after )
* [`fail()` ](#fail )
* [`option()` ](#option )
* [`cd()` ](#cd )
* [`within()` ](#within )
* [`run()` ](#run )
* [`runLocally()` ](#runLocally )
* [`test()` ](#test )
* [`testLocally()` ](#testLocally )
* [`on()` ](#on )
* [`invoke()` ](#invoke )
* [`upload()` ](#upload )
* [`download()` ](#download )
* [`info()` ](#info )
* [`warning()` ](#warning )
* [`writeln()` ](#writeln )
* [`write()` ](#write )
* [`parse()` ](#parse )
* [`set()` ](#set )
* [`add()` ](#add )
* [`get()` ](#get )
* [`has()` ](#has )
* [`ask()` ](#ask )
* [`askChoice()` ](#askChoice )
* [`askConfirmation()` ](#askConfirmation )
* [`askHiddenResponse()` ](#askHiddenResponse )
* [`input()` ](#input )
* [`output()` ](#output )
* [`commandExist()` ](#commandExist )
* [`commandSupportsOption()` ](#commandSupportsOption )
* [`locateBinaryPath()` ](#locateBinaryPath )
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## host()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
host(...$hostname)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## localhost()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
localhost(...$hostnames)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## getHost()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
getHost(string $alias)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Get host by host alias.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## currentHost()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
currentHost()
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Get current host.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## inventory()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
inventory($file)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Load list of hosts from file
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## desc()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
desc($title = null)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Set task description.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## task()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
task($name, $body = null)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Define a new task and save to tasks list.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Alternatively get a defined task.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## before()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
before($task, $do)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Call that task before specified task runs.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## after()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
after($task, $do)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Call that task after specified task runs.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## fail()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
fail($task, $do)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Setup which task run on failure of first.
2019-07-02 08:05:15 +03:00
2020-04-25 23:00:08 +03:00
2020-09-30 09:25:41 +02:00
## option()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
option($name, $shortcut = null, $mode = null, $description = '', $default = null)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Add users options.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## cd()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
cd($path)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Change the current working directory.
2019-07-02 08:05:15 +03:00
2020-04-25 23:00:08 +03:00
2020-09-30 09:25:41 +02:00
## within()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
within($path, $callback)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Execute a callback within a specific directory and revert back to the initial working directory.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## run()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
run($command, $options = [])
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Executes given command on remote host.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Options:
- `timeout` - Sets the process timeout (max. runtime). The timeout in seconds (default: 300 sec).
- `secret` - Placeholder `%secret%` can be used in command. Placeholder will be replaced with this value and will not appear in any logs.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Examples:
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
run('echo hello world');
run('cd {{deploy_path}} & & git status');
run('password %secret%', ['secret' => getenv('CI_SECRET')]);
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
$path = run('readlink {{deploy_path}}/current');
run("echo $path");
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## runLocally()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
runLocally($command, $options = [])
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Execute commands on local machine
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## test()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
test($command)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Run test command.
Example:
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
if (test('[ -d {{release_path}} ]')) {
...
}
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## testLocally()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
testLocally($command)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Run test command locally.
Example:
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
testLocally('[ -d {{local_release_path}} ]')
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## on()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
on($hosts, callable $callback)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Iterate other hosts, allowing to call run func in callback.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## invoke()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
invoke($task)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Run task
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## upload()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
upload(string $source, string $destination, $config = [])
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Upload file or directory to host.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
> You may have noticed that there is a trailing slash (/) at the end of the first argument in the above command, this is necessary to mean “the contents of build“.
>
> The alternative, without the trailing slash, would place build, including the directory, within public. This would create a hierarchy that looks like: {{release_path}}/public/build
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## download()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
download(string $source, string $destination, $config = [])
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Download file or directory from host
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## info()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
info($message)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Writes an info message.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## warning()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
warning($message)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Writes an warning message.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## writeln()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
writeln($message, $options = 0)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Writes a message to the output and adds a newline at the end.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## write()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
write($message, $options = 0)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Writes a message to the output.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## parse()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
parse($value)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Parse set values.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## set()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
set($name, $value)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Setup configuration option.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## add()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
add($name, $array)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Merge new config params to existing config array.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## get()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
get($name, $default = null)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Get configuration value.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## has()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
has($name)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
Check if there is such configuration option.
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## ask()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
ask($message, $default = null, $autocomplete = null)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## askChoice()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
askChoice($message, array $availableChoices, $default = null, $multiselect = false)
```
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## askConfirmation()
```php
askConfirmation($message, $default = false)
```
## askHiddenResponse()
```php
askHiddenResponse(string $message)
```
## input()
```php
input()
```
## output()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
output()
```
2019-07-02 08:05:15 +03:00
2020-08-14 23:11:49 +02:00
2020-09-30 09:25:41 +02:00
## commandExist()
2020-08-14 23:11:49 +02:00
2020-09-30 09:25:41 +02:00
```php
commandExist($command)
```
2020-08-14 23:11:49 +02:00
2020-09-30 09:25:41 +02:00
Check if command exists
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
## commandSupportsOption()
2019-07-02 08:05:15 +03:00
2020-09-30 09:25:41 +02:00
```php
commandSupportsOption($command, $option)
```
2019-07-02 08:05:15 +03:00
2020-08-14 23:11:49 +02:00
2020-09-30 09:25:41 +02:00
## locateBinaryPath()
2020-08-14 23:11:49 +02:00
2020-09-30 09:25:41 +02:00
```php
locateBinaryPath($name)
```
2020-08-14 23:11:49 +02:00