This repository has been archived on 2023-10-21. You can view files and clone it, but cannot push or open issues or pull requests.
patchouli/startup.php
2020-12-24 03:25:10 +00:00

24 lines
995 B
PHP

<?php
namespace Patchouli;
define('PAT_STARTUP', microtime(true));
define('PAT_ROOT', __DIR__);
define('PAT_DEBUG', is_file(PAT_ROOT . '/.debug'));
define('PAT_PUB', PAT_ROOT . '/public'); // WWW visible
define('PAT_SRC', PAT_ROOT . '/src'); // Patchouli namespace
define('PAT_LIB', PAT_ROOT . '/lib'); // Other unresolved namespaces
ini_set('display_errors', PAT_DEBUG ? 'on' : 'off');
error_reporting(PAT_DEBUG ? -1 : 0);
mb_internal_encoding('utf-8');
set_include_path(PAT_SRC . PATH_SEPARATOR . PAT_LIB . PATH_SEPARATOR . get_include_path());
spl_autoload_register(function(string $className) {
$parts = explode('\\', trim($className, '\\'), 2);
if($parts[0] === __NAMESPACE__)
require_once PAT_SRC . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $parts[1]) . '.php';
else
require_once PAT_LIB . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
});