forked from vanilla/vanilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.php
90 lines (78 loc) · 2.82 KB
/
environment.php
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
<?php
/**
* Bare minimum setup of the environment to use Vanilla's classes.
*
* @author Alexandre (DaazKu) Chouinard <alexandre.c@vanillaforums.com>
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
*/
// Environment
define("ENVIRONMENT_PHP_VERSION", "7.2");
define("ENVIRONMENT_PHP_NEXT_VERSION", "7.3");
if (version_compare(phpversion(), ENVIRONMENT_PHP_VERSION) < 0) {
die("Vanilla requires PHP " . ENVIRONMENT_PHP_VERSION . " or greater.");
}
// Define the constants we need to get going.
if (!defined("APPLICATION")) {
define("APPLICATION", "Vanilla");
}
if (!defined("DS")) {
define("DS", DIRECTORY_SEPARATOR);
}
if (!defined("PATH_ROOT")) {
define("PATH_ROOT", getcwd());
}
/**
* Bootstrap Before
*
* This file gives developers the opportunity to hook into Garden before any
* real work has been done. Nothing has been included yet, aside from this file.
* No Garden features are available yet.
*/
$isWeb = PHP_SAPI !== "cli" && isset($_SERVER["REQUEST_METHOD"]);
if ($isWeb && file_exists(PATH_ROOT . "/conf/bootstrap.before.php")) {
require_once PATH_ROOT . "/conf/bootstrap.before.php";
}
/**
* Define Core Constants
*
* Garden depends on the presence of a certain base set of defines that allow it
* to be aware of its own place within the system. These are conditionally
* defined here, in case they've already been set by a zealous bootstrap.before.
*/
// Path to the primary configuration file.
if (!defined("PATH_CONF")) {
define("PATH_CONF", PATH_ROOT . "/conf");
}
// Include default constants.
require_once PATH_CONF . "/constants.php";
// Make sure a default time zone is set.
// Do NOT edit this. See config `Garden.GuestTimeZone`.
date_default_timezone_set("UTC");
// Make sure the mb_* functions are utf8.
if (function_exists("mb_internal_encoding")) {
mb_internal_encoding("UTF-8");
}
ini_set("default_charset", "UTF-8");
// Include the core autoloader.
if (!include_once PATH_ROOT . "/vendor/autoload.php") {
die("Could not find the autoloader. Did you forget to run 'composer install' in '" . PATH_ROOT . "' ?\n");
}
spl_autoload_register([Vanilla\AliasLoader::class, "autoload"]);
// Classes are autoloaded
// Let's load up the application version.
if (!defined("APPLICATION_VERSION")) {
$version = "unknown";
try {
$version = \Vanilla\FileUtils::getCached(PATH_CACHE . "/version.php", function () {
$versionJsonContents = \Vanilla\FileUtils::getArray(PATH_ROOT . "/version.json");
return $versionJsonContents["version"] ?? "unknown";
});
} catch (Throwable $e) {
// Don't completely blow up if we can't load this file.
trigger_error($e->getMessage(), E_USER_WARNING);
}
// Rules for the versioning
// {Release version}-{? SNAPSHOT if it's a dev build}
define("APPLICATION_VERSION", $version);
}