xref: /webtrees/app/Webtrees.php (revision 6ccdf4f0fd1b65a5d54259c969912382ce49629d)
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 and themes. These are used as URLs and folder paths.
56    public const MODULES_PATH = 'modules_v4/';
57
58    // Location of themes (core and custom).
59    public const THEMES_PATH = 'themes/';
60
61    /**
62     * Initialise the application.
63     *
64     * @return void
65     */
66    public static function init(): void
67    {
68        mb_internal_encoding('UTF-8');
69
70        // Show all errors and warnings in development, fewer in production.
71        error_reporting(Webtrees::ERROR_REPORTING);
72
73        // PHP requires a time zone to be set. We'll set a better one later on.
74        date_default_timezone_set('UTC');
75
76        set_error_handler(Handler::phpErrorHandler());
77        set_exception_handler(Handler::phpExceptionHandler());
78    }
79}
80