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 = 41; 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 // Location of CSS/JS/etc. assets. See also webpack.mix.js. 61 public const ASSETS_PATH = 'public/assets-2.0.0/'; 62 63 /** 64 * Initialise the application. 65 * 66 * @return void 67 */ 68 public static function init() 69 { 70 // Show all errors and warnings in development, fewer in production. 71 error_reporting(self::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 // Convert PHP warnings/notices into exceptions 77 set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool { 78 // Ignore errors that are silenced with '@' 79 if (error_reporting() & $errno) { 80 throw new ErrorException($errstr, 0, $errno, $errfile, $errline); 81 } 82 83 return true; 84 }); 85 } 86} 87