xref: /webtrees/app/Webtrees.php (revision 963ec568e3b0d5dfb79dacee3aa1b22d2fc68d9a)
18d0ebef0SGreg Roach<?php
28d0ebef0SGreg Roach/**
38d0ebef0SGreg Roach * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
58d0ebef0SGreg Roach * This program is free software: you can redistribute it and/or modify
68d0ebef0SGreg Roach * it under the terms of the GNU General Public License as published by
78d0ebef0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88d0ebef0SGreg Roach * (at your option) any later version.
98d0ebef0SGreg Roach * This program is distributed in the hope that it will be useful,
108d0ebef0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118d0ebef0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128d0ebef0SGreg Roach * GNU General Public License for more details.
138d0ebef0SGreg Roach * You should have received a copy of the GNU General Public License
148d0ebef0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158d0ebef0SGreg Roach */
168d0ebef0SGreg Roachdeclare(strict_types=1);
178d0ebef0SGreg Roach
188d0ebef0SGreg Roachnamespace Fisharebest\Webtrees;
198d0ebef0SGreg Roach
208d0ebef0SGreg Roachuse ErrorException;
218d0ebef0SGreg Roachuse function date_default_timezone_set;
228d0ebef0SGreg Roachuse function error_reporting;
238d0ebef0SGreg Roachuse function set_error_handler;
248d0ebef0SGreg Roach
258d0ebef0SGreg Roach/**
268d0ebef0SGreg Roach * Definitions for the webtrees application.
278d0ebef0SGreg Roach */
288d0ebef0SGreg Roachclass Webtrees
298d0ebef0SGreg Roach{
308d0ebef0SGreg Roach    // Location of the file containing the database connection details.
3116d6367aSGreg Roach    public const CONFIG_FILE = __DIR__ . '/../data/config.ini.php';
328d0ebef0SGreg Roach
338d0ebef0SGreg Roach    // Enable debugging on development builds.
3416d6367aSGreg Roach    public const DEBUG = self::STABILITY !== '';
358d0ebef0SGreg Roach
368d0ebef0SGreg Roach    // We want to know about all PHP errors during development, and fewer in production.
3716d6367aSGreg Roach    public const ERROR_REPORTING = self::DEBUG ? E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED : E_ALL;
388d0ebef0SGreg Roach
398d0ebef0SGreg Roach    // The name of the application.
4016d6367aSGreg Roach    public const NAME = 'webtrees';
418d0ebef0SGreg Roach
428d0ebef0SGreg Roach    // Required version of database tables/columns/indexes/etc.
4316d6367aSGreg Roach    public const SCHEMA_VERSION = 41;
448d0ebef0SGreg Roach
458d0ebef0SGreg Roach    // e.g. "dev", "alpha", "beta.3", etc.
46*963ec568SGreg Roach    public const STABILITY = 'alpha.5';
478d0ebef0SGreg Roach
488d0ebef0SGreg Roach    // Project website.
4916d6367aSGreg Roach    public const URL = 'https://www.webtrees.net/';
508d0ebef0SGreg Roach
518d0ebef0SGreg Roach    // Version number
5216d6367aSGreg Roach    public const VERSION = '2.0.0' . (self::STABILITY === '' ? '' : '-') . self::STABILITY;
538d0ebef0SGreg Roach
548d0ebef0SGreg Roach    // Location of our modules and themes. These are used as URLs and folder paths.
5549a243cbSGreg Roach    public const MODULES_PATH = 'modules_v4/';
568d0ebef0SGreg Roach
578d0ebef0SGreg Roach    // Location of themes (core and custom).
5816d6367aSGreg Roach    public const THEMES_PATH = 'themes/';
598d0ebef0SGreg Roach
608d0ebef0SGreg Roach    // Location of CSS/JS/etc. assets. See also webpack.mix.js.
6116d6367aSGreg Roach    public const ASSETS_PATH = 'public/assets-2.0.0/';
628d0ebef0SGreg Roach
638d0ebef0SGreg Roach    /**
648d0ebef0SGreg Roach     * Initialise the application.
658d0ebef0SGreg Roach     *
668d0ebef0SGreg Roach     * @return void
678d0ebef0SGreg Roach     */
688d0ebef0SGreg Roach    public static function init()
698d0ebef0SGreg Roach    {
708d0ebef0SGreg Roach        // Show all errors and warnings in development, fewer in production.
718d0ebef0SGreg Roach        error_reporting(self::ERROR_REPORTING);
728d0ebef0SGreg Roach
738d0ebef0SGreg Roach        // PHP requires a time zone to be set. We'll set a better one later on.
748d0ebef0SGreg Roach        date_default_timezone_set('UTC');
758d0ebef0SGreg Roach
768d0ebef0SGreg Roach        // Convert PHP warnings/notices into exceptions
778d0ebef0SGreg Roach        set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool {
788d0ebef0SGreg Roach            // Ignore errors that are silenced with '@'
798d0ebef0SGreg Roach            if (error_reporting() & $errno) {
808d0ebef0SGreg Roach                throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
818d0ebef0SGreg Roach            }
828d0ebef0SGreg Roach
838d0ebef0SGreg Roach            return true;
848d0ebef0SGreg Roach        });
858d0ebef0SGreg Roach    }
868d0ebef0SGreg Roach}
87