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 ErrorException; 21use function date_default_timezone_set; 22use function error_reporting; 23use function set_error_handler; 24 25/** 26 * Definitions for the webtrees application. 27 */ 28class Webtrees 29{ 30 // Location of the file containing the database connection details. 31 public const CONFIG_FILE = __DIR__ . '/../data/config.ini.php'; 32 33 // Enable debugging on development builds. 34 public const DEBUG = self::STABILITY !== ''; 35 36 // We want to know about all PHP errors during development, and fewer in production. 37 public const ERROR_REPORTING = self::DEBUG ? E_ALL | E_STRICT | E_NOTICE | E_DEPRECATED : E_ALL; 38 39 // The name of the application. 40 public const NAME = 'webtrees'; 41 42 // Required version of database tables/columns/indexes/etc. 43 public const SCHEMA_VERSION = 43; 44 45 // e.g. "dev", "alpha", "beta.3", etc. 46 public const STABILITY = 'alpha.5'; 47 48 // Project website. 49 public const URL = 'https://www.webtrees.net/'; 50 51 // Version number 52 public const VERSION = '2.0.0' . (self::STABILITY === '' ? '' : '-') . self::STABILITY; 53 54 // Location of our modules and themes. These are used as URLs and folder paths. 55 public const MODULES_PATH = 'modules_v4/'; 56 57 // Location of themes (core and custom). 58 public const THEMES_PATH = 'themes/'; 59 60 /** 61 * Initialise the application. 62 * 63 * @return void 64 */ 65 public static function init() 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 // Convert PHP warnings/notices into exceptions 74 set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool { 75 // Ignore errors that are silenced with '@' 76 if (error_reporting() & $errno) { 77 throw new ErrorException($errstr, 0, $errno, $errfile, $errline); 78 } 79 80 return true; 81 }); 82 } 83} 84