forked from marionnewlevant/craftcom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craft
executable file
·54 lines (41 loc) · 1.41 KB
/
craft
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
#!/usr/bin/env php
<?php
/**
* Craft console bootstrap file
*/
define('CRAFT_BASE_PATH', __DIR__);
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');
// Composer autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';
// dotenv
if (file_exists(CRAFT_BASE_PATH.'/.env')) {
$dotenv = new Dotenv\Dotenv(CRAFT_BASE_PATH);
$dotenv->load();
}
if ($storagePath = getenv('CRAFT_STORAGE_PATH')) {
define('CRAFT_STORAGE_PATH', $storagePath);
}
if ($keyPath = getenv('LICENSE_KEY_PATH')) {
define('CRAFT_LICENSE_KEY_PATH', $keyPath);
}
// Manually load environment variables so they're available to the PHP CLI
$envVars = '/opt/elasticbeanstalk/support/envvars';
if (file_exists($envVars) && is_file($envVars)) {
$contents = file_get_contents($envVars);
foreach (explode("\n", $contents) as $line) {
if (empty($line)) {
continue;
}
$new_line = str_replace('export ', '', $line);
$first_part = strpos($new_line, '=');
$last_part = substr($new_line, $first_part, strlen($new_line));
$variable_value = str_replace(['=', '"'], '', $last_part);
$variable_name = substr($new_line, 0, $first_part);
putenv($variable_name. '=' .$variable_value);
}
}
define('CRAFT_ENVIRONMENT', getenv('CRAFT_ENV') ?: 'prod');
// Craft
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/console.php';
$exitCode = $app->run();
exit($exitCode);