xref: /webtrees/app/Webtrees.php (revision 2ebb07b4bd8cf7010946ea4d75bb6160666157f6)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees;
19
20use function date_default_timezone_set;
21use function error_reporting;
22use Fisharebest\Webtrees\Exceptions\Handler;
23use function set_error_handler;
24use function set_exception_handler;
25
26/**
27 * Definitions for the webtrees application.
28 */
29class Webtrees
30{
31    // Location of the file containing the database connection details.
32    public const CONFIG_FILE = __DIR__ . '/../data/config.ini.php';
33
34    // Enable debugging on development builds.
35    public const DEBUG = self::STABILITY !== '';
36
37    // We want to know about all PHP errors during development, and fewer in production.
38    public const ERROR_REPORTING = self::DEBUG ? E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED : E_ALL;
39
40    // The name of the application.
41    public const NAME = 'webtrees';
42
43    // Required version of database tables/columns/indexes/etc.
44    public const SCHEMA_VERSION = 43;
45
46    // e.g. "dev", "alpha", "beta.3", etc.
47    public const STABILITY = 'alpha.5';
48
49    // Project website.
50    public const URL = 'https://www.webtrees.net/';
51
52    // Version number
53    public const VERSION = '2.0.0' . (self::STABILITY === '' ? '' : '-') . self::STABILITY;
54
55    // Location of our modules.
56    public const MODULES_PATH = 'modules_v4/';
57
58    /**
59     * Initialise the application.
60     *
61     * @return void
62     */
63    public static function init(): void
64    {
65        mb_internal_encoding('UTF-8');
66
67        // Show all errors and warnings in development, fewer in production.
68        error_reporting(self::ERROR_REPORTING);
69
70        // PHP requires a time zone to be set. We'll set a better one later on.
71        date_default_timezone_set('UTC');
72
73        set_error_handler(Handler::phpErrorHandler());
74        set_exception_handler(Handler::phpExceptionHandler());
75    }
76}
77