-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
101 lines (89 loc) · 2.01 KB
/
bootstrap.php
File metadata and controls
101 lines (89 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Bootstrap file for all examples.
*/
// Error reporting.
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
date_default_timezone_set('Europe/Brussels');
// CLI only.
if (PHP_SAPI !== 'cli') {
exit('This example should only be run from a Command Line Interface.' . PHP_EOL);
}
// Get the local config file.
$configFile = __DIR__ . '/config.php';
if (!file_exists($configFile)) {
exit('Config file is missing. See README.md how to create one.' . PHP_EOL);
}
require_once __DIR__ . '/config.php';
// AutoLoader to get all required libraries.
require_once __DIR__ . '/../vendor/autoload.php';
$output = new Symfony\Component\Console\Output\ConsoleOutput();
/**
* Helper function to print a line to the output.
*
* @param string $text
* @param mixed ...$arguments
* Text replacements (see sprintf()).
*/
function printText(string $text, ...$arguments): void
{
echo $arguments
? sprintf($text, ...$arguments)
: $text;
echo PHP_EOL;
}
/**
* Helper to print a separator.
*/
function printLine(): void
{
printText(str_repeat('-', 80));
}
/**
* Helper to print a page title.
*
* @param string $title
* @param mixed ...$arguments
* Text replacements (see sprintf()).
*/
function printTitle(string $title, ...$arguments): void
{
printText('');
printLine();
printText($title, ...$arguments);
printLine();
printText('');
}
/**
* Helper to print a footer.
*/
function printFooter(): void
{
printText('');
printLine();
printText('');
}
/**
* Helper to print a step.
*
* @param string $step
* @param mixed ...$arguments
* Text replacements (see sprintf()).
*/
function printStep(string $step, ...$arguments): void
{
printText('→ ' . $step, ...$arguments);
}
/**
* Helper to print a bullet.
*
* @param string $text
* @param mixed ...$arguments
* Text replacements (see sprintf()).
*/
function printBullet(string $text, ...$arguments): void
{
printText(' • ' . $text, ...$arguments);
}