1 | <?php |
||
5 | class ConfigFileBuilder |
||
6 | { |
||
7 | const DEFAULT_PHP_VERSION = '7.2'; |
||
8 | |||
9 | protected $laravelHooks = [ |
||
10 | // 'artisan:storage:link', |
||
11 | 'artisan:view:clear', |
||
12 | 'artisan:cache:clear', |
||
13 | 'artisan:config:clear', |
||
14 | 'artisan:config:cache', |
||
15 | 'artisan:optimize', |
||
16 | ]; |
||
17 | |||
18 | protected $lumenHooks = [ |
||
19 | 'artisan:cache:clear', |
||
20 | 'artisan:optimize', |
||
21 | ]; |
||
22 | |||
23 | protected $configs = [ |
||
24 | 'default' => 'basic', |
||
25 | 'strategies' => [], |
||
26 | |||
27 | 'hooks' => [ |
||
28 | 'start' => [ |
||
29 | ], |
||
30 | 'build' => [], |
||
31 | 'ready' => [], |
||
32 | 'done' => [], |
||
33 | 'success' => [ |
||
34 | 'success:notify', |
||
35 | 'record:revision:log', |
||
36 | ], |
||
37 | 'fail' => [ |
||
38 | 'failed:notify', |
||
39 | ], |
||
40 | ], |
||
41 | 'options' => [ |
||
42 | 'application' => 'LaravelDeployer', |
||
43 | 'keep_releases' => 6, |
||
44 | 'php_fpm_service' => 'php7.2-fpm', |
||
45 | 'group_notify' => false, |
||
46 | 'notify_channel_url' => '', |
||
47 | ], |
||
48 | 'hosts' => [ |
||
49 | 'example.com' => [ |
||
50 | 'deploy_path' => '/var/www/example.com', |
||
51 | 'user' => 'root', |
||
52 | 'branch' => 'master', |
||
53 | 'forwardAgent' => true, |
||
54 | 'multiplexing' => true, |
||
55 | 'stage' => 'devel', |
||
56 | ], |
||
57 | ], |
||
58 | 'localhost' => [], |
||
59 | 'include' => [], |
||
60 | 'custom_deployer_file' => false, |
||
61 | ]; |
||
62 | |||
63 | public function __construct() |
||
71 | |||
72 | /** |
||
73 | * Return the configuration value at the given key. |
||
74 | * |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function get($key, $default = null) |
||
81 | |||
82 | /** |
||
83 | * Update the configuration array with the given key/value pair. |
||
84 | * |
||
85 | * @return ConfigFileGenerator |
||
86 | */ |
||
87 | public function set($key, $value) |
||
93 | |||
94 | /** |
||
95 | * Append the given value to the configuration array at the given key. |
||
96 | * |
||
97 | * @return ConfigFileGenerator |
||
98 | */ |
||
99 | public function add($key, $value) |
||
110 | |||
111 | /** |
||
112 | * Return current host configurations at the given key. |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function getHost($key) |
||
120 | |||
121 | /** |
||
122 | * Return the name of the first host in the configurations. |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getHostname() |
||
130 | |||
131 | /** |
||
132 | * Update the host configurations with the given key/value pair. |
||
133 | * |
||
134 | * @return ConfigFileGenerator |
||
135 | */ |
||
136 | public function setHost($key, $value) |
||
156 | |||
157 | /** |
||
158 | * Set up defaults values more suitable for forge servers. |
||
159 | * |
||
160 | * @return ConfigFileGenerator |
||
161 | */ |
||
162 | public function useForge($phpVersion = self::DEFAULT_PHP_VERSION) |
||
170 | |||
171 | /** |
||
172 | * Reload PHP-FPM after every deployment. |
||
173 | * |
||
174 | * @param string $phpVersion The php-fpm version to reload |
||
175 | * @return ConfigFileGenerator |
||
176 | */ |
||
177 | public function reloadFpm($phpVersion = self::DEFAULT_PHP_VERSION) |
||
184 | |||
185 | /** |
||
186 | * Build a config file object based on the information |
||
187 | * collected so far. |
||
188 | * |
||
189 | * @return ConfigFile |
||
190 | */ |
||
191 | public function build() |
||
195 | } |
||
196 |