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

24 lines
995 B
PHP
Raw Normal View History

2020-12-23 01:44:45 +00:00
<?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);
2020-12-24 03:25:10 +00:00
mb_internal_encoding('utf-8');
2020-12-23 01:44:45 +00:00
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';
});